Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MSBuild批处理的工作方式与我预期的不同。我怎样才能修好它?_Msbuild_Batching - Fatal编程技术网

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

MSBuild批处理的工作方式与我预期的不同。下面是演示“问题”行为的MSBuild脚本的快速示例:

<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>
如果像这样执行msbuild
msbuild。\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>

%(平台身份)

之所以得到这个结果,是因为您合并了此行中的所有文件(所以这并不是意外):“”。我正试图找到一个解决办法。。。