Share via

itemgroup transformation ordering

Rudolf Meier 291 Reputation points
2022-04-07T09:09:40.303+00:00

I have something like this

<ItemGroup>
<MyVal Include="@(MyItems->'%(out)\%(class).h')" />
<MyVal Include="'%(MyItems.out)\%(MyItems.class).h'" />
<MyVal Include="'%(MyItems.html)'" Condition="'%(MyItems.html)' != ''" />
</ItemGroup>

1)
is the first and second line "the same" ?? or do I get a similar result?

2)
how would you do this to change the order of the evaluation

from "a->x1;b->x1;c->x1;a->x2;b->x2;c->x2" to "a->x1;a->x2;b->x1;b->x2;c->x1;c->x2"

so, first evaluate every of those lines for the first item, then for the second one... and so on

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,836 Reputation points Microsoft External Staff
    2022-04-08T07:39:33.403+00:00

    Hi @Rudolf Meier ,

    Welcome to Microsoft Q&A forum.

    First of all, in MSBuild, @ denotes referencing item(s), % denotes referencing metadata and $ denotes referencing properties. For % there are some MSBuild well-known item metadata such as %(RootDir), %(Filename), %(RelativeDir) and %(Directory) etc. Also in some situation, %<xx> can be used to escape special characters.

    For your first question, no, they are not the same. The -> operator is used for Item functions or for transforming something like metadata of item type.

    The first line uses -> so it means transforming the metadata represented by MyItems to the right-hand side corresponding metadata. You can check more details here: MSBuild Transforms.

    The second line usually means including a simple .h file. And %(…)\%(…).h represents its directory. But please note, this line may be not work, as if you want to include a simple file, even if you want to combine or custom the directory, you can reference the parts of the directory from property group instead of item group, it will be easier to understand or to check. For example <MyVal Include="$(…)\$(…).h">

    For your second question, it’s a little abstract, could you share more details? Do a,b,c mean the meta data of one certain item type and x1, x2, x3 means the file to transform to? If yes, the order of the transforming is by default(the order of combination of expression can be changed), you can try to change the metadata list order in MSBuild and make them match the related file, but still, it is abstract, and I am not very sure what you really want.

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.