Msbuild: Lazy evaluation optimizations don't respect item transforms

Created on 18 Jun 2020  路  1Comment  路  Source: dotnet/msbuild

Update and Remove don't respect item transforms at evaluation time; they apply to all items instead of just the ones that were selected by the item transform.

This was the case for Update for a long time; Remove was working correctly until #5350.

Steps to reproduce

Project file

<Project>
  <ItemGroup>
    <Foo Include="C:\*" />
    <Foo Include="x" />

    <!-- <Foo Update="@(Foo->WithMetadataValue('Filename', 'x'))" Bar="Baz" /> -->
    <Foo Remove="@(Foo->WithMetadataValue('Filename', 'x'))" />
  </ItemGroup>

  <Target Name="Go">
    <Message Importance="High"
             Text="Foo=@(Foo->'%(Filename) %(Bar)')" />
  </Target>
</Project>

Expected behavior

Only the x item removed/updated

Actual behavior

Go:
  Foo=

Environment data

msbuild /version output: 16.7.0-preview-20309-02+d6862eb21

Most helpful comment

Thanks for chasing this down @safern!

>All comments

Thanks for chasing this down @safern!

Was this page helpful?
0 / 5 - 0 ratings