Search code examples
msbuildmulticore

Enable multiproc in Msbuild via API


With Msbuild v3.5 I can include the "/m" switch to enable multiprocessor support . However I cannot find an equivalent property that hangs off of anything in Microsoft.Build.BuildEngine. How do I enable this setting via the API?

I tried to discover this myself by reflecting over Msbuild.exe (thanks Lutz!) but it doesn't use the BuildEngine instead using System.Threading.Thread directly.


Solution

  • Does this...

    http://blogs.msdn.com/msbuild/archive/2007/10/22/enabling-multiprocessor-support-in-an-msbuild-host.aspx

    ... answer your question?

    Essentially, it looks as if you use the constructor of Engine that takes a parameter for the number of CPUs to use.

    http://msdn.microsoft.com/en-us/library/bb300140.aspx

    public Engine(
        BuildPropertyGroup globalProperties,
        ToolsetDefinitionLocations locations,
        int numberOfCpus,
        string localNodeProviderParameters
    )