Skip to content

[Bug]: Chained item function isn't respected in item update statement #9636

Open
@ViktorHofer

Description

@ViktorHofer

Issue Description

Apparently, msbuild ignores chained ->WithMetadataValue('...', '...') item functions in an item update statement.

Steps to Reproduce

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <KnownFrameworkReference Update="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('TargetFramework', 'net8.0'))"
      RuntimePackRuntimeIdentifiers="XXX;%(RuntimePackRuntimeIdentifiers)" />
    <!-- Test with a separate item... -->
    <_asdf Include="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('TargetFramework', 'net8.0'))" />
  </ItemGroup>

</Project>

dotnet build /bl
Open binary log and search for KnownFrameworkReference. Observe that the RuntimePackRuntimeIdentifier metdata is updated on all "Microsoft.NETCore.App" items, not just the one with the "TargetFramework=net8.0" metadata.

The same works with an Include statement. Search for _asdf and observe that only one item is listed.

Expected Behavior

Only one item should be updated instead of all the ones with Identity=Microsoft.NETCore.App.

Actual Behavior

All Identity="Microsoft.NETCore.App" KnownFrameworkReference items get updated, regardless of the TargetFramework metdata on the item.

Analysis

No response

Versions & Configurations

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions