开发者

why doesn't Visual Studio 2010 (msbuild?) build faster?

开发者 https://www.devze.com 2023-03-20 13:18 出处:网络
Oftentimes when building a large solution with many projects in Visual Studio 2010, Windows 7 Resource Monitor will show that devenv.exe as Not Responding, however Average CPU reads a low number like

Oftentimes when building a large solution with many projects in Visual Studio 2010, Windows 7 Resource Monitor will show that devenv.exe as Not Responding, however Average CPU reads a low number like 0.91 like shown:

why doesn't Visual Studio 2010 (msbuild?) build faster?

and this is on Windows 7 x64 with a AMD Phenom II 920 4-core CPU, 8 GB RAM. Visual Studio is not responding, 开发者_开发问答yet it hardly seems to be using any CPU resources.

When I tried running the build with msbuild.exe and the switch "/maxcpucount:4", the Average CPU value still stays low, and the RHS graphs never show a value above 5-10%.

Why doesn't Visual Studio 2010 (or msbuild) seem to be taking advantage of the CPU(s) during a build?


Building a project potentially involves a lot of disk I/O. This can take a fair bit of time, but will not produce much in the way of CPU load.

As for why it shows as not responding, my guess would be that the build process is for some reason (as in, someone did a poor job of implementing it) blocking the application from responding to requests from the OS. An application doesn't need to reach 100% CPU utilization to be considered "Not Responding", it just needs to get its main thread stuck somewhere that prevents it from responding to the OS in a timely fashion.


It seems that MSBuild does not like to build multiple projects in parallel, only multiple files in one project in parallel.


Why is it slow and doesn't work as expected? Well, because its built from scratch using cutting edge technologies. That's why!

(Rant: VS 2010 is huge step back IMHO. VS 2008 is much more stable/responsive (and works) but lets leave the personal opinions aside)

Two workarounds to take adavantage of multiple cores:

  • Set MSBuild as an external tool as outlined here and assign it a shortcut (like Ctrl+Shft+B) for quick access.
  • Set BuildInParallel attrib of MSBuild task to true

    <Target Name="RunInParallel">
      <MSBuild BuildInParallel="true"
               Projects="@(Projects)"
               Targets="RunCodeAnalysis">
      </MSBuild>
    </Target>
    
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号