Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compare value to any values (multiple values/items)? #5847

Open
Denis535 opened this issue Oct 30, 2020 · 3 comments
Open

How to compare value to any values (multiple values/items)? #5847

Denis535 opened this issue Oct 30, 2020 · 3 comments
Labels
Area: Language Issues impacting the MSBuild programming language. question triaged
Milestone

Comments

@Denis535
Copy link

Denis535 commented Oct 30, 2020

I have the values and keys. The values are pointing on keys.

<ItemGroup>
    <Key Include="0" />
    <Key Include="3" />
</ItemGroup>

<ItemGroup>
    <Val Include="A0" Key="0" />
    <Val Include="A1" Key="0" />
    <Val Include="B"  Key="1" />
    <Val Include="C"  Key="2" />
    <Val Include="D0" Key="3" />
    <Val Include="D1" Key="3" />
</ItemGroup>

I need to filter values which are pointing on the any key in my list. But none of the following methods works ((

<Message Text="@(Val->WithMetadataValue( 'Key', %(Key.Identity) ))" Importance="high" />
<Message Text="@(Val)" Condition="%(Val.Key) == %(Key.Identity)" Importance="high" />
<Message Text="@(Val)" Condition="@(Key->AnyHaveMetadataValue( 'Identity', %(Val.Key) ) )" Importance="high" />

Is it possible to do it?

@Denis535 Denis535 added the needs-triage Have yet to determine what bucket this goes in. label Oct 30, 2020
@Denis535 Denis535 changed the title How to compare value/item to any values/Items? How to compare value/item to any values/Items (compare with multiple values/items)? Oct 30, 2020
@Denis535
Copy link
Author

Denis535 commented Oct 30, 2020

Why does the last line not work? AnyHaveMetadataValue looks like the right function for my case.

@Denis535
Copy link
Author

Denis535 commented Oct 31, 2020

Function can not accept %(...) syntax. So, you need a temporary property and target batching.

<Target Name="Tmp" AfterTargets="AfterBuild" Outputs="%(Key.Identity)">
    <PropertyGroup>
        <Key>%(Key.Identity)</Key>
    </PropertyGroup>
    <Message Text="%(Key.Identity): @(Val->WithMetadataValue( 'Key', $(Key) ))" Importance="high" />
</Target>

<Target Name="Tmp2" AfterTargets="AfterBuild" Outputs="%(Val.Identity)">
    <PropertyGroup>
        <Val_Key>%(Val.Key)</Val_Key>
    </PropertyGroup>
    <Message Text="%(Val.Identity): %(Val.Key)" Condition="@(Key->AnyHaveMetadataValue( 'Identity', $(Val_Key) ))" Importance="high" />
</Target>

Is there a better way?

@benvillalobos benvillalobos added this to the Discussion milestone Nov 4, 2020
@benvillalobos benvillalobos added the Area: Language Issues impacting the MSBuild programming language. label Nov 4, 2020
@Denis535 Denis535 changed the title How to compare value/item to any values/Items (compare with multiple values/items)? How to compare value to any values (compare with multiple values/items)? Nov 9, 2020
@Denis535 Denis535 changed the title How to compare value to any values (compare with multiple values/items)? How to compare value to any values (multiple values/items)? Nov 9, 2020
@Denis535
Copy link
Author

We need a function WithAnyMetadataValue.

@benvillalobos benvillalobos self-assigned this Nov 11, 2020
@benvillalobos benvillalobos added question and removed needs-triage Have yet to determine what bucket this goes in. labels Nov 11, 2020
@benvillalobos benvillalobos removed their assignment Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Language Issues impacting the MSBuild programming language. question triaged
Projects
None yet
Development

No branches or pull requests

3 participants