Skip to content

WithMetadataValue does not accept batching argument #7675

Open
@iskiselev

Description

@iskiselev

Issue Description

WithMetadataValue item function does not return anything when parameter is from batch

Steps to Reproduce

<Project>
  <ItemGroup>
    <ItemA Include="1.txt" M="a" />
    <ItemA Include="2.txt" M="b" />
    <ItemA Include="3.txt" M="c" />
    <ItemB Include="a.txt" />
    <ItemB Include="c.txt" />
  </ItemGroup>
  

  <Target Name="Build" >
    <Warning Text="* @(ItemA->WithMetadataValue('M','%(Filename)'))" Condition="'%(ItemB.Filename)' != ''"/>
  </Target>
</Project>

Expected Behavior

Two warnings with matching ItemA in each:

warning : * 1.txt
warning : * 3.txt

Actual Behavior

Two empty warnings:

warning : *
warning : *

Analysis

In most case there is a way to workaround the issue using few temporary ItemGroups and different way of batching.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: LanguageIssues impacting the MSBuild programming language.bugtriaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions