顺便说一句,我不明白为什么 IDE 有以下选项
并行构建多个项目和多个文件,但不是
多种配置。
其实,在 VS IDE 中,Batch Build UI 有一个选项来配置项目的配置。
但它可以为项目配置多个configuration、Platform.....但不会并行处理构建项目。
建议
我建议您可以使用 msbuild 脚本,然后使用 MSBuild 命令行 来运行多个平台的多个项目。
1)创建一个名为test.proj的文件
2)在其中添加这些:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectFile Include="C:\xxxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=Release</Properties>
</ProjectFile>
<ProjectFile Include="C:\xxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=Debug</Properties>
</ProjectFile>
<ProjectFile Include="C:\xxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=xxx</Properties>
</ProjectFile>
.....
// add any configuration like this and remember to include the related vcxproj and even the same vcxproj has to be written for different configurations.
</ItemGroup>
<Target Name="ParelBuild">
<MSBuild Projects="@(ProjectFile)" BuildInParallel="true" Targets="Build" />
</Target>
</Project>
见this similar issue。
3) 注意:Developer Command Prompt for VS2015 没有显示并行构建的功能,我感到很困惑。
所以要并行构建,我建议你可以下载Build Tool for VS2019,它可以与VS2019分开安装,并且支持低版本的MSBuild 14.0。而且我已经测试成功了。
(下载链接位于All Downloads-->Tools for Visual Studio 2019)
4) 使用此 MSBuild 命令行进行构建:
msbuild test.proj -t:ParelBuild -v:normal -m:30
效果如下:
更新 1
在不同的时间建立你自己的项目组合,你可以试试这些:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectFile Include="C:\xxxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=Release</Properties>
</ProjectFile>
<ProjectFile Include="C:\xxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=Debug</Properties>
</ProjectFile>
<ProjectFile Include="C:\xxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=xxx</Properties>
</ProjectFile>
.....
// add any configuration like this and remember to include the related vcxproj and even the same vcxproj has to be written for different configurations.
</ItemGroup>
<ItemGroup>
<ProjectFile1 Include="C:\xxxx\ConsoleApplication1.vcxproj">
<Properties>Configuration=Release</Properties>
</ProjectFile1>
<ProjectFile1 Include="C:\xxx\xxx.sln">
<Properties>Configuration=Debug</Properties>
</ProjectFile1>
........
</ItemGroup>
<Target Name="ParelBuild1">
<MSBuild Projects="@(ProjectFile1)" BuildInParallel="true" Targets="Build" />
</Target>
</Project>
那么先一次构建 ParelBuild 目标:
msbuild test.proj -t:ParelBuild
在它之后,在另一个时间,执行这个:
msbuild test.proj -t:ParelBuild1
这允许您在不同时间点并行执行组合项目。