双回路中的MSBuild? [英] Double-Loop in msbuild?
问题描述
结果
我正在写的MSBuild这将使两批一步到位的脚本。结果
例如:2 ItemGroups
I'm writing a script for msbuild which should make two batches in one step.
Example: 2 ItemGroups
<ItemGroup>
<GroupOne Include="1" />
<GroupOne Include="2" />
</ItemGroup>
<ItemGroup>
<GroupTwo Include="A" />
<GroupTwo Include="B" />
</ItemGroup>
这两个组应在相互循环:
These two groups should be looped within each other:
<Message Text="%(GroupOne.Identity) %(GroupTwo.Identity)" />
我希望做的MSBuild的结果了两批给的
I hoped that msbuild makes the result up of both batches giving
1 A
2 A
1 B
2 B
作为结果。结果
但是,这并没有发生。相反,它返回以下没用的废物:
as result.
But that didn't happen. Instead, it returned the following useless crap:
1
2
A
B
做它像
<PropertyGroup>
<GroupOneStep>%(GroupOne.Identity)</GroupOneStep>
</PropertyGroup>
<Message Text="$(GroupOneStep) %(GroupTwo.Identity)" />
品牌
2 A
2 B
任何提示?我要疯了。 : - (
Any hints? I'm going mad. :-(
PS:这里有一个关于该主题的博文 - 遗憾的是它并没有因为propsed那里工作:
<一href=\"http://blogs.msdn.com/b/giuliov/archive/2010/04/30/gotcha-msbuild-nested-loops-double-batching.aspx\">http://blogs.msdn.com/b/giuliov/archive/2010/04/30/gotcha-msbuild-nested-loops-double-batching.aspx
PS: Here's a blogpost about the topic - unfortunately it doesn't work as propsed there: http://blogs.msdn.com/b/giuliov/archive/2010/04/30/gotcha-msbuild-nested-loops-double-batching.aspx
推荐答案
尝试这个创建使用从组1中的身份,并从身份分配元数据到新的项目组组2的一个新的ItemGroup(或任何其它元数据)然后用配料遍历新组。
Try this to create a new ItemGroup using the identity from group 1 and assigning metadata to the new item group from the identity (or any other metadata) of group 2. Then use batching to iterate over the new group.
<CreateItem Include="@(GroupOne)" AdditionalMetadata="Option1=%(GroupTwo.Identity)">
<Output ItemName="_Group_Merged" TaskParameter="Include"/>
</CreateItem>
<Message Text="%(_Group_Merged.Identity)-%(_Group_Merged.Option1)" />
如果你有两个以上的组,您可以添加createItem中的条目第三组并入_Group_Merged然后遍历,联合组。
If you have more than two groups you can add CreateItem entries to merge the third group into _Group_Merged and then iterate over that combined group.
<CreateItem Include="@(_Group_Merged)" AdditionalMetadata="Option2=%(GroupThree.Identity)">
<Output ItemName="_Group_Merged2" TaskParameter="Include"/>
</CreateItem>
<Message Text="%(_Group_Merged2.Identity)-%(_Group_Merged2.Option1)-%(_Group_Merged2.Option2)" />
这篇关于双回路中的MSBuild?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!