How to enable multiprocessor compilation in call to msbuild but not in Visual Studio

msbuild, visual-studio-2010

Solution

I've found the answer: properties can be passed to the MSBuild task. This can specify any of the properties for the CL Task, so msbuild can be invoked with:

msbuild file.sln /property:MultiProcessorCompilation=true

There's also a useful article on tuning VS2010 parallel build performance here: http://blogs.msdn.com/b/msbuild/archive/2010/03/08/tuning-c-build-parallelism-in-vs2010.aspx

Problem

There are a number of teams in our company who use a subset of common libraries. Some projects are able to use different build scripts, and so in one project we'd like to be able to build with `msbuild` using the `/m` option to build projects in parallel (some other projects use `devenv` to build). This option can be set in a build script so the projects don't need to change. The question is how we can also apply the `/MP` option to `cl.exe` to allow multiprocessor builds inside each project, but without changing the common libraries. Inside Visual Studio you can apply a user property sheet, which won't change the project files, but is there a way of doing the same thing for `msbuild` by providing an argument or property sheet that can apply custom build settings without changing the projects? EDIT: Maybe a simpler way of summarising the question is: can I add custom arguments to the `cl.exe` process when calling `msbuild`?

Original source