issue with using MSBUILD with maxcpucount option

4.1k views Asked by At

I am using MsBuild on a 4 core machine. I am giving the following command line to build 4 projects belonging to a big VC++ solution ( having more than 4 projects ALL with no mutual dependencies ). I am using Visual Studio 2008.

To speed up the build time I am trying to take advantage of the maxcpucount options but it seems not working. I was expecting that each core would build each of the 4 projects I am providing at command line. Unfortunately I measured the time of building and with or without the maxcpucount option I have the same exact result.

C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe MyVCppSolution.sln 
     /t:ProjA;ProjB;ProjC;ProjD /m

Do you know what I am doing wrong here?

Is a correct way to say "builds 4 projects of MyVCppSolution.sln solution at once" or should I run manually 4 processes each building a single project of the solution up to 4?

1

There are 1 answers

1
Taylor Bird On

MSBuild can projects in parallel. Your command line call (using /t) is asking for targets to build in parallel, which isn't exactly the design. You also have to set a flag in the core .proj file for parallel

To acheive what you want (4 items in parallel using all avail cores) you need to have an "overall" proj file that invokes msbuild and has the BuildInParallel parameter set to true. Then that call, calls your other projects. The combination of /m on msbuild.exe and BuillInParallel will give you what you want.

So that would like: (If you wanted ProjA, B, C, D built in parallel)

File buildall.proj

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion=”3.5”>
     <Target Name="default">
          <MSBuild Projects="proja.proj, projb.proj, probc.proj,prod.proj" BuildInParallel="true"/>
     </Target>
</Project>

Then you'd call buildall with

msbuild.exe buildall.proj /m:4