- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含大量项目 (.sln
) 的大型 Visual Studio 2010 解决方案文件 (~50
)。每个项目大致由 20
组成.cpp
和 .h
文件。在快速的 Intel i7 机器上构建整个项目大约需要 2 个小时,所有依赖项都本地缓存在快速 SSD 上。
我正在尝试 replicate an existing experiment I found on this topic ,并且需要澄清如何:
MSBuild.exe
获取这些更改也适用于自动命令行构建. /m
和
/maxcpucount
选项一样吗?我有
read an article on the /m
option,这似乎建立了更多
项目 在平行下。这似乎与我通过 GUI 中的以下操作设置的选项相同:
Maximum number of parallel project builds
/MP
,我可以通过以下方式在 GUI 中访问:
Multi-processor Compilation
.cpp
并行文件,但没有选项指定多少,除非我必须在文本框中手动设置它(即:
/MP 4
或
/MP4
。
/MP
要工作,我需要禁用最小重建(即:
Enabled Minimal Rebuild: No (/GM-)
),它也不适用于预编译的头文件。我通过使预编译头文件成为解决方案首先构建的专用项目,在所有其他项目之前解决了预编译头文件问题。
.cpp
),通过命令行使用 MSBuild,并确认它们按预期工作?我上面的假设是否也正确?
我的最终目标是测试使用最多使用的内核总数构建项目,或者如果我的构建过程受 I/O 限制而不是 CPU 限制,甚至可能使其重载。 我可以通过以下方式在 Linux 中轻松做到这一点:
NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
NUMJOBS="$(echo "$NUMCPUS*1.5" | bc)"
NUMJOBS="$(printf '%.0f' $NUMJOBS)"
alias pmake='time nice make -j$NUMJOBS'
make
自动构建多达 12 个
.cpp
并行文件,处理隐式构建规则/依赖项等。我试图在 Visual Studio Professional 和 MSBuild 中实现相同的目标。当我的构建受 I/O 限制时,这种方法最能将所有内核保持在
~100%
。用法。
最佳答案
/MP
编译器 ( cl.exe
) 和 /m
的开关msbuild.exe
的选项确实是要走的路。这里有一些相关的documentation提取物:
The /MP option causes the compiler to create one or more copies of itself, each in a separate process. Then these copies simultaneously compile the source files. Optional Argument: The maximum number of processes that the compiler can create. If you omit the processMax argument, the compiler retrieves the number of effective processors on your computer from the operating system, and creates a process for each processor. The /MP option is incompatible with some compiler options and language features. If you use an incompatible compiler option with the /MP option, the compiler issues warning D9030 and ignores the /MP option
Examples suppose you specify the following command line:
cl /MP7 a.cpp b.cpp c.cpp d.cpp e.cpp
In this case the compiler uses five processes because that is the lesser of five source files and a maximum of seven processes. Alternatively, suppose your computer has two effective processors and you specify the following command line:
cl /MP a.cpp b.cpp c.cpp
In this case the operating system reports two processors; therefore, the compiler uses two processes in its calculation. As a result, the compiler will execute the build with two processes because that is the lesser of two processes and three source files.
cl /MP3 a.cpp b.cpp c.cpp
的命令。同时,您将同时运行 6 个编译器进程。这是您所追求的行为,也是 msbuild 可以做的事情。
msbuild /?
的输出:
/maxcpucount[:n] Specifies the maximum number of concurrent processes to build with. If the switch is not used, the default value used is 1. If the switch is used without a value MSBuild will use up to the number of processors on the computer. (Short form: /m[:n])
BuildInParallel is an optional boolean parameter on a MSBuild task. When BuildInParallel is set to true (its default value), multiple worker processes are generated to build as many projects at the same time as possible. For this to work correctly, the /maxcpucount switch must be set to a value greater than 1, and the system must be at least dual-core or have two or more processors.
msbuild /m my.vcxproj
在一个典型的项目上,这不会做任何特别的事情,因为只有一个项目要构建。但是,如果在 msbuild 文件中调用了 MsBuild 任务,例如
<MsBuild Projects="@(ListOfProjects)" BuildInParallel="True"/>
<max num cl processes> * <max num msbuild instances>
并行编译。这取决于您的构建机器什么是最佳的,如果您希望您可以使用这些选项(为了有效地做到这一点,您的每个项目都将导入一个公共(public)属性表,您可以在其中设置/MP 选项,否则您必须编辑所有这些都是单独的)并查看构建完成时 msbuild 报告的耗时。我总是将/m 和/MP 的参数保留为默认值,因为我不希望使用我的项目的其他开发人员有可能的次优配置,并且因为它很容易最大化 CPU。
关于visual-studio - MSBuild - 如何并行构建多个文件和项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33787023/
我经常使用 SSMS 查询数据和构建数据集,我的 IT 部门负责数据库管理。 最近我发现了 Azure Data Studio,我喜欢: 智能感知 源代码控制(例如使用 Git) 来自社区的扩展 SQ
我想根据我使用的 visual studio 版本编译不同的东西,比如 #if VISUAL_STUDIO_VERSION > 2015 eventH?.Invoke(this, EventArgs.
我们的开发团队计划从 visual studio 2005 升级到 visual studio 2010 -- 跳过 visual studio 2008。 大部分项目是VB ASP.NET项目,使用
我的Visual Studio 2015无法构建2010平台工具集。它说: The build tools for Visual Studio 2010 (v100) cannot be found.
我目前正在使用 Visual Studio 2015 来编程 ASP.NET Core 应用程序。我对安装 Visual Studio 2017 有以下疑问: 什么被认为是最佳实践和/或最干净的方法?
尝试从扩展和更新获取 Visual Studio 扩展时,出现以下错误:- 向 visualstudiogallery.msdn.microsoft.com/Services/VStudio/Exte
这个问题在这里已经有了答案: Can Visual Studio Code and VS 2012 be installed on same computer? (1 个回答) 关闭去年。 在安装了
作为标准安装的一部分,Visual Studio Code 带有一个名为“Monokai Dimmed”的颜色主题。 有没有办法将它移植到 Visual Studio 2015?我检查了社区主题( h
我想开始编程 CUDA。 我已经安装了 Visual Studio 2010 Express。 我还安装了 nVidia nSight Visual Studio。 而且我具备所有常见的先决条件(Ne
Visual Studio Community Edition是否可以使用Visual Studio Online帐户上的存储库? 我一直为包含在Online帐户中的Visual Studio Onl
我有一个我一直在开发的应用程序,但在 android studio 上遇到了问题。当我点击“build->run”然后选择我的设备时,应用程序永远不会在我的手机上运行(并且自动出现的android-s
我正在使用Visual Studio2010。我面临的一个问题是,当我创建一个新的Web项目时,Visual Studio将创建该项目,并且不会在解决方案资源管理器中显示其解决方案。 另一件事是,我想
我通读了这里的许多帖子,却找不到一个有效的明确答案。因此,在花了一些时间使它生效之后,我认为应该发布它。 问题:发布配置文件将建立在服务器上,但不会发布。 解: 确保已安装Microsoft Wind
我正在尝试使用Visual Studio 2012构建针对.NET 3.5的C++ CLI应用程序。 通过安装Visual Studio 2008,并指定v90平台工具集,我已经在一台机器上进行了这项
我在 Microsoft Visual Studios 2013 中有一个项目,我想在 Microsoft Visual Studios 2010 中打开它。有什么简单的方法吗?还是我必须在2010年
我想知道,如果我发送一个解决方案文件夹(它是用 visual studio C# 编写的),您可以在 visual studio for mac 中打开解决方案吗? 在visual studio 20
有没有办法在 Visual Studio Code 和 Visual Studio 中设置相同的快捷方式(而不必每次都手动更改它们)? 例如,我在 Visual Studio Code 中经常使用 A
我刚开始了解 Visual Studio Code。我想知道,我可以将 Visual Studio 替换为所有 .NET 开发相关的工作吗? 我可以节省 Visual Studio 许可的成本吗? V
我安装了具有有效许可证(Visual Studio 订阅)的 Visual Studio 2019 企业版(VS 2019 16.1.4),它运行良好。 突然之间,当我尝试打开项目或项目中的任何文件时
我一直在使用 Compass 编译 Windows 环境中的 sass 文件,无论是在命令行上还是使用 Compass-app 来查看目录。 我刚刚开始使用 Visual Studio(专业版 201
我是一名优秀的程序员,十分优秀!