MSBuildStructuredLog icon indicating copy to clipboard operation
MSBuildStructuredLog copied to clipboard

'Update' ItemGroups in a Target aren't in the Log tree

Open mschofie opened this issue 7 years ago • 3 comments

I have an MSBuild Target that updates Items' metadata using an ItemGroup with the 'Update' attribute:

<Project DefaultTargets="Build">
  <ItemGroup>
    <Thing Include="One">
      <Size>Tiny</Size>
    </Thing>
  </ItemGroup>

  <Target Name="Build">
    <ItemGroup>
      <Thing Update="@(Thing)">
        <Size>Large</Size>
      </Thing>
    </ItemGroup>

    <Message Text="Things: @(Thing) - %(Thing.Size)"
             Importance="High" />
  </Target>
</Project>

Building this with MSBuild yields the output: Things: One - Large - the ItemGroup with Update changed the Thing Item's metadata from Tiny to Large. But viewing the log for this in MSBuildStructuredLogViewer doesn't render a tree-node in the log for the "Update Item". If I were to change the 'Update' attribute to an 'Include' attribute, the node appears in the log (there's an Add Item node in the tree), but I get different behavior (I end up with two Thing Items).

I looked through the code to fix this, but it looks like there's no msbuild logging for the Update - using msbuild 15.7.180.61344 or 15.8.139-preview+g5951330944. So there may be msbuild work needed?

mschofie avatar Jul 24 '18 18:07 mschofie

Indeed, looks like an MSBuild omission. I've filed https://github.com/Microsoft/msbuild/issues/3538 to investigate it there. As soon as MSBuild fixes it, we'll get it for free.

KirillOsenkov avatar Jul 25 '18 00:07 KirillOsenkov

This is so needed, a common pattern is to modify items after another target produces it. (Run before or after a target and change the input or output of said target)

davidfowl avatar Sep 07 '20 17:09 davidfowl

Yes, please add your voice on https://github.com/dotnet/msbuild/issues/3538 and https://github.com/dotnet/msbuild/issues/2835

KirillOsenkov avatar Sep 07 '20 19:09 KirillOsenkov