Search code examples
cakebuild

Cake enabling Parallel MSBuild


In a cake file, how do I "enable parallel build" on MsBuild actions. I get the message output to the terminal to "please add the "/m" switch", but I don't see how to do this in the MS Build Settings that I pass into the MsBuild method.


Solution

  • Have a look at this section of code:

    https://github.com/cake-build/cake/blob/37642a71049a2708af13886e34364fe68959f2d7/src/Cake.Common/Tools/MSBuild/MSBuildRunner.cs#L58

    You can use the MaxCpuCount' property to control that flag.

    For example:

        var msbuildSettings = new MSBuildSettings()
                .WithProperty("TreatWarningsAsErrors","true")
                .WithTarget("Build")
                .SetMaxCpuCount(0)
                .SetConfiguration("release")
                );
    
        MSBuild("<path to solution file", msbuildSettings);