MSBuild批处理的工作方式与我预期的不同。我怎样才能修好它?
MSBuild批处理的工作方式与我预期的不同。下面是演示“问题”行为的MSBuild脚本的快速示例:MSBuild批处理的工作方式与我预期的不同。我怎样才能修好它?,msbuild,batching,Msbuild,Batching,MSBuild批处理的工作方式与我预期的不同。下面是演示“问题”行为的MSBuild脚本的快速示例: <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <ItemGroup> <Platform Condition="('$(Platform)' == 'All') Or ('$(P
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<Platform Condition="('$(Platform)' == 'All') Or ('$(Platform)' == 'x86')" Include="x86" />
<Platform Condition="('$(Platform)' == 'All') Or ('$(Platform)' == 'x64')" Include="x64" />
</ItemGroup>
<Target Name="Build">
<ItemGroup>
<OutputFiles Include="%(Platform.Identity)\*.txt"/>
</ItemGroup>
<Message Importance="high" Text="%(Platform.Identity): @(OutputFiles)" />
</Target>
</Project>
如果像这样执行msbuildmsbuild。\test.proj/p:Platform=All
,则输出如下所示:
...
Build:
x86: x86\test-x86.txt;x64\test-x64.txt
x64: x86\test-x86.txt;x64\test-x64.txt
...
...
Build:
x86: x86\test-x86.txt
x64: x64\test-x64.txt
...
我期望/希望输出结果如下所示:
...
Build:
x86: x86\test-x86.txt;x64\test-x64.txt
x64: x86\test-x86.txt;x64\test-x64.txt
...
...
Build:
x86: x86\test-x86.txt
x64: x64\test-x64.txt
...
换句话说,我希望根据消息
任务的批处理方式对输出文件
项目组中的项目进行分组/筛选
如何更改脚本以获得所需的行为?我希望解决方案不涉及对目标/任务区域中的“平台”值进行硬编码。在这里。您需要使用每个Platform.Identity中断输出文件。 我已经测试过了,这是你想要的:
<Project ToolsVersion="3.5" DefaultTargets="Build;" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Platform Condition="('$(Platform)' == 'All') Or ('$(Platform)' == 'x86')" Include="x86"/>
<Platform Condition="('$(Platform)' == 'All') Or ('$(Platform)' == 'x64')" Include="x64"/>
</ItemGroup>
<Target Name="Build">
<ItemGroup>
<OutputFiles Include="%(Platform.Identity)\*.txt">
<Flavor>%(Platform.Identity)</Flavor>
</OutputFiles>
</ItemGroup>
<Message Importance="high" Text="%(OutputFiles.Flavor): %(OutputFiles.Identity)" />
</Target>
</Project>
%(平台身份)
之所以得到这个结果,是因为您合并了此行中的所有文件(所以这并不是意外):“”。我正试图找到一个解决办法。。。