msbuild 中的双循环?
我正在为 msbuild 编写一个脚本,该脚本应该一步生成两批。
示例:2 个 ItemGroups
<ItemGroup>
<GroupOne Include="1" />
<GroupOne Include="2" />
</ItemGroup>
<ItemGroup>
<GroupTwo Include="A" />
<GroupTwo Include="B" />
</ItemGroup>
这两个组应该彼此循环:
<Message Text="%(GroupOne.Identity) %(GroupTwo.Identity)" />
我希望 msbuild 将两个批次的结果
1 A
2 A
1 B
2 B
作为结果。
但那并没有发生。相反,它返回了以下无用的废话:
1
2
A
B
按照下面链接中的博客建议的方式(使用本地属性组)进行操作
<PropertyGroup>
<GroupOneStep>%(GroupOne.Identity)</GroupOneStep>
</PropertyGroup>
<Message Text="$(GroupOneStep) %(GroupTwo.Identity)" />
有
2 A
2 B
任何提示吗?我要疯了。 :-(
PS:这是一篇关于该主题的博文 - 不幸的是它并不像那里所建议的那样工作: http:// /blogs.msdn.com/b/giuliov/archive/2010/04/30/gotcha-msbuild-nested-loops-double-batching.aspx
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)" />
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
Doing it the way the blog from the link below proposes (using a local propertygroup) like
<PropertyGroup>
<GroupOneStep>%(GroupOne.Identity)</GroupOneStep>
</PropertyGroup>
<Message Text="$(GroupOneStep) %(GroupTwo.Identity)" />
makes
2 A
2 B
Any hints? I'm going mad. :-(
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于两个嵌套循环,这是有效的:
结果:
For two nested loops this works:
Results in:
人们还可以使用Dog Ears技术制作三重嵌套循环。
One can also make triple nested loops using the technique of Dog Ears.
尝试使用组 1 中的标识创建一个新的 ItemGroup,并根据组 2 的标识(或任何其他元数据)将元数据分配给新项目组。然后使用批处理来迭代新组。
如果您有两个以上的组,则可以添加 CreateItem 条目以将第三个组合并到 _Group_Merged 中,然后迭代该组合组。
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.
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.
这是一个更简单的解决方案。
使用中间项组
Combined
创建消息任务批处理的中间项组。如果你有更多的 ItemMetaData,你需要为第二个 ItemGroup 显式处理它,引用符号 @ 包含的 ItemGroup 自动包含 ItemMetaData,因此你只需要从第二组通过明确引用。这是一个例子:
This is a much simpler solution.
Using an intermediate Item group
Combined
to create an intermediate item group that the Message task batches on.If you have more ItemMetaData you'll need to handle that explicitly for the second ItemGroup, The ItemGroup included with the reference symbol @ automatically includes the ItemMetaData, so you'll just need to create the additional MetaData from the second group by referencing explicitly. Here's an example: