KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.44k stars 190 forks source link

Handle ITaskItem parameter in task runner #547

Closed 0xced closed 2 years ago

0xced commented 2 years ago

Having to convert a ITaskItem[] to a ITaskItem may happen with MSBuild target batching. For example, this happens with the Microsoft.SourceLink.GitHub.GetSourceLinkUrl task where the SourceRoot parameter is somehow translated from what should be a property with metadata to a list of task items.

Without this translation, the following error would occur:

System.ArgumentException: Object of type 'Microsoft.Build.Framework.ITaskItem[]' cannot be converted to type 'Microsoft.Build.Framework.ITaskItem'.

0xced commented 2 years ago

Here's what the SourceRoot looks like in the viewer for the Microsoft.SourceLink.GitHub.GetSourceLinkUrl task.

Screenshot of the SourceRoot as task items
KirillOsenkov commented 2 years ago

Thanks!