已连接项目组的 MSBuild 元数据
我希望加入两个项目组:
<ItemGroup>
<ServerTypeA Include="ServerA;ServerB;">
<MetaDataA>A</MetaDataA>
</ServerTypeA>
</ItemGroup>
<ItemGroup>
<ServerTypeB Include="ServerB;ServerC;">
<MetaDataB>B</MetaDataB>
</ServerTypeB>
</ItemGroup>
使用常规联接将为我提供一个包含 4 个项目的集合:
ServerA with Metadata A;
ServerB with Metadata A;
ServerB with Metadata B;
ServerC with Metadata B;
如何创建以下集合:
ServerA with Metadata A
ServerB with Metadata A & B
ServerC with Metadata B
I have two item groups that I wish to join:
<ItemGroup>
<ServerTypeA Include="ServerA;ServerB;">
<MetaDataA>A</MetaDataA>
</ServerTypeA>
</ItemGroup>
<ItemGroup>
<ServerTypeB Include="ServerB;ServerC;">
<MetaDataB>B</MetaDataB>
</ServerTypeB>
</ItemGroup>
Using the regular join will give me a collection with 4 items:
ServerA with Metadata A;
ServerB with Metadata A;
ServerB with Metadata B;
ServerC with Metadata B;
How can I create the following collection:
ServerA with Metadata A
ServerB with Metadata A & B
ServerC with Metadata B
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是有可能的。您
必须可以手动执行连接。以下是如何执行此操作的示例(需要 msbuild 3.5 或更高版本):
运行
JoinServers
目标将产生以下输出:使用更好的答案更新
这个问题向我指出了一个更简单的解决方案。
基本上,您使用 转换修饰符 和
%(Identity) 执行连接。
您可以将上面的所有 3 个目标替换为以下目标以获得相同的输出。
It's possible. You
have tocan manually perform the join.Here's an example of how to do it (msbuild 3.5 or greater required):
Running the
JoinServers
target will produce the following output:Update with a better answer
This question pointed me to a much simpler solution.
Basically you use Transform modifiers with
%(Identity)
to perform the join.You can replace all 3 targets from above with the following to obtain the same output.