MSBuild并非所有内核都可以构建 [英] MSBuild not building with all cores

查看:74
本文介绍了MSBuild并非所有内核都可以构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个配置有Visual Studios 2008的项目.当我打开IDE并进行构建时,系统上的所有内核都将用于构建该项目.但是,当我尝试从命令行进行构建时,仅使用了1个内核.这是我正在运行的命令:

I have a project configured with Visual Studios 2008. When I open the IDE and hit build, all the cores on my system are used to build the project. However, when I try and build from the command line only 1 core is used. Here is the command that I am running:

C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild VTK.sln /m /fl /tv:3.5 /p:Configuration=RelWithDebInfo

通过阅读文档,似乎/m开关应该告诉MSBuild使用所有内核,但事实并非如此.有什么想法可以使它使用所有内核吗?

From reading the docs, it would appear that the /m switch should tell MSBuild to use all cores, but it does not. Any ideas how to make it use all the cores?

谢谢

推荐答案

好吧,实际上/m选项指定了用于构建的最大并发进程数".也就是说,并行启动msbuild.exe进程的最大数量以并行构建您的项目(每个进程最多可以构建一个项目).与使用所有核心"完全不同.虽然,虽然/m选项的长格式名称/maxcpucount可能会暗示其他含义,但是对它的描述应该可以更好地说明发生了什么:

Well, actually the /m option specifies the "the maximum number of concurrent processes to build with". That is, the maximum number of msbuild.exe processes to start in parallel to build your projects in parallel (each process will build one project at most). Something quite different than "using all cores". Although, admittedly, the long form name of the /m option, /maxcpucount might hint otherwise, the description of it should give a better indication of what is going on:

  /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])

现在,如果您的解决方案不允许并行构建项目,例如,因为您的每个项目都是对另一个项目的依赖项(例如,构建P2需要P1,构建P3需要P2,依此类推. ),则不会看到任何并行构建.根据构建完成的快慢,您也不会在所有内核上看到任何相关活动(例如,使用任务管理器),因为CPU图形的闪烁"可能并不十分准确地表明实际发生的情况(请注意构建过程是否正确).也是相当耗费I/O的,这并不显示CPU负载.

Now, if your Solution doesn't allow for projects to build in parallel, for example because each of your project is a dependency for another one (like P1 is required to build P2, P2 is required to project P3, etc.) you won't see any parallel builds happening. Depending on how fast builds complete, you would also not see any relevant activity on all cores (e.g. using Task Manager) because the "flickering" of the CPU graphs might not really be accurate as to what is going really on (mind a build is also pretty I/O intensive, which doesn't show looking at CPU load).

但是,您应该看到(例如,使用Process Explorer或Task Manager)多个msbuild.exe进程,这些进程与您拥有的内核/CPU的数量(或作为可选数字传递给服务器的等效数字)相匹配. /m选项.

You should, however, see (for example using Process Explorer or Task Manager) a number of msbuild.exe processes that match the number of cores/CPUs you have (or the equivalent number that you pass as an optional number to the /m option.

您可能还想参考此SO问题.此外,搜索"parallel msbuild"也会产生一些包含更多信息的热门文章.

You may also want to refer to this SO question . Also searching for "parallel msbuild" produces some good hits with more information.

这篇关于MSBuild并非所有内核都可以构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆