问题描述
我对 IDE 非常熟悉(23 年),但对 MSBuild 完全不熟悉.
我已阅读并重新阅读
但它可以为项目配置多个configuration
、Platform
.....但不会并行处理构建项目.
建议
我建议您可以使用 msbuild 脚本,然后使用 MSBuild 命令行 来运行多个平台的多个项目.
1) 创建一个名为 test.proj
2)在其中添加这些:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><项目组><ProjectFile 包含="C:xxxxConsoleApplication1.vcxproj"><Properties>Configuration=Release</Properties></项目文件><ProjectFile 包含="C:xxxConsoleApplication1.vcxproj"><属性>配置=调试</属性></项目文件><ProjectFile 包含="C:xxxConsoleApplication1.vcxproj"><属性>配置=xxx</属性></项目文件>......//添加任何这样的配置并记住包含相关的 vcxproj,即使是相同的 vcxproj 也必须为不同的配置编写.</项目组><目标名称="ParelBuild"><MSBuild Projects="@(ProjectFile)" BuildInParallel="true" Targets="Build"/></目标></项目>
请参阅
更新 1
在不同的时间建立你自己的项目组合,你可以试试这些:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><项目组><ProjectFile 包含="C:xxxxConsoleApplication1.vcxproj"><Properties>Configuration=Release</Properties></项目文件><ProjectFile 包含="C:xxxConsoleApplication1.vcxproj"><属性>配置=调试</属性></项目文件><ProjectFile 包含="C:xxxConsoleApplication1.vcxproj"><属性>配置=xxx</属性></项目文件>......//添加任何这样的配置并记住包含相关的 vcxproj,即使是相同的 vcxproj 也必须为不同的配置编写.</项目组><项目组><ProjectFile1 包含="C:xxxxConsoleApplication1.vcxproj"><Properties>Configuration=Release</Properties></ProjectFile1><ProjectFile1 包含="C:xxxxxx.sln"><属性>配置=调试</属性></ProjectFile1>...........</项目组><目标名称="ParelBuild1"><MSBuild Projects="@(ProjectFile1)" BuildInParallel="true" Targets="Build"/></目标></项目>
那么先一次构建 ParelBuild 目标:
msbuild test.proj -t:ParelBuild
在它之后,在另一个时间,执行这个:
msbuild test.proj -t:ParelBuild1
这允许您在不同时间点并行执行组合项目.
I am very familiar with the IDE (23 years), but not at all with MSBuild.
I have read and re-read https://docs.microsoft.com/en-gb/visualstudio/msbuild/building-multiple-projects-in-parallel-with-msbuild?view=vs-2015 about making MSBuild build multiple configurations in parallel, but I don't understand how to hook it to "batch build" (or infact MSBuild, which would be my lat resort).
To describe what I want to achieve differently, if I mad 30 copies of the project all pointing to the same code with one config each I could then batch build and they would make good use of many cores, with 30 configurations of one project, they all build serially making very poor use of CPU cores.
On a side note, I don't understand why the IDE has options for building multiple projects and multiple files in parallel, but not multiple configurations.
On a side note, I don't understand why the IDE has options for building multiple projects and multiple files in parallel, but not multiple configurations.
Actually, in VS IDE, Batch Build UI has an option to config the configuration for projects.
But it can configure multiple configuration
, Platform
..... for projects but does not process build projects in parallel.
Suggestion
I suggest you could use a msbuild script to and then use MSBuild Command Line to run several projects with multiple platforms.
1) Create a file called test.proj
2) add these in it:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectFile Include="C:xxxxConsoleApplication1.vcxproj">
<Properties>Configuration=Release</Properties>
</ProjectFile>
<ProjectFile Include="C:xxxConsoleApplication1.vcxproj">
<Properties>Configuration=Debug</Properties>
</ProjectFile>
<ProjectFile Include="C:xxxConsoleApplication1.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>
See this similar issue.
3) Note: Developer Command Prompt for VS2015
does not show the features of parallel build and I feel quite confused.
So to parallel build, I suggest you could download Build Tool for VS2019 which can be installed separately from VS2019 and supports lower versions of MSBuild 14.0. And I have tested successfully.
(the download link is under All Downloads-->Tools for Visual Studio 2019)
4) use this MSBuild command line to build:
msbuild test.proj -t:ParelBuild -v:normal -m:30
The effect is as follows:
Update 1
Build your own portfolio of projects at different times and you can try these:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectFile Include="C:xxxxConsoleApplication1.vcxproj">
<Properties>Configuration=Release</Properties>
</ProjectFile>
<ProjectFile Include="C:xxxConsoleApplication1.vcxproj">
<Properties>Configuration=Debug</Properties>
</ProjectFile>
<ProjectFile Include="C:xxxConsoleApplication1.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:xxxxConsoleApplication1.vcxproj">
<Properties>Configuration=Release</Properties>
</ProjectFile1>
<ProjectFile1 Include="C:xxxxxx.sln">
<Properties>Configuration=Debug</Properties>
</ProjectFile1>
........
</ItemGroup>
<Target Name="ParelBuild1">
<MSBuild Projects="@(ProjectFile1)" BuildInParallel="true" Targets="Build" />
</Target>
</Project>
Then first build the ParelBuild target at one time:
msbuild test.proj -t:ParelBuild
After it, at another time, execute this:
msbuild test.proj -t:ParelBuild1
This allows you to execute combined projects in parallel at different points in time.
这篇关于如何使用 BatchBuild 并行构建多个 C++ Visual Studio v2015+ 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!