gpt4 book ai didi

msbuild - MSBuild 中的交叉连接项组

转载 作者:行者123 更新时间:2023-12-04 17:51:11 31 4
gpt4 key购买 nike

鉴于这样的事情..

 <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ConfigFiles Include="*.config" />

<DatabaseConfig Include="ABC">
<Database>DB1</Database>
<CsString>Database</CsString>
</DatabaseConfig>

<DatabaseConfig Include="DEF">
<Database>DB2</Database>
<CsString>Logging</CsString>
</DatabaseConfig>
</ItemGroup>


<Target Name="test" >
<!-- Some sort of join here (or somewhere)... -->
<Message Text=" %(Combined.ConfigFile) %(Combined.Database) " />
</Target>
</Project>

我希望输出是这样的..(给定两个文件 one.config 和 two.config)
one.config DB1
two.config DB1
one.config DB2
two.config DB2

(顺序不重要,只是两个ItemGroups的完整笛卡尔积)

最佳答案

这似乎是一个整洁的解决方案:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ConfigFiles Include="*.config" />

<DatabaseConfig Include="ABC">
<Database>DB1</Database>
<CsString>Database</CsString>
</DatabaseConfig>

<DatabaseConfig Include="DEF">
<Database>DB2</Database>
<CsString>Logging</CsString>
</DatabaseConfig>
</ItemGroup>

<Target Name="test" >
<ItemGroup>
<Combined Include="@(DatabaseConfig)">
<ConfigFile>%(ConfigFiles.Identity)</ConfigFile>
</Combined>
</ItemGroup>
<Message Text=" %(Combined.ConfigFile) %(Combined.Database) " />
</Target>
</Project>

关于msbuild - MSBuild 中的交叉连接项组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15914145/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com