I am trying to use the MsBuild api to run a build frpm C#. The following seems to work, but only runs the build single threaded. I really need this to run multi-threaded. When I run from the command line by running msbuild I can use the /m switch to start a parallel build. How can I achieve the same programmatically?
var logger = new BasicLogger();
var buildParameters = new BuildParameters()
{
Loggers = new List<Microsoft.Build.Framework.ILogger>() { logger },
DetailedSummary = false,
EnableNodeReuse = false,
OnlyLogCriticalEvents = false,
ShutdownInProcNodeOnBuildFinish = true
};
var globalProperties = new Dictionary<string, string>
{
{ "Platform", platform },
{ "Configuration", configuration },
{ "BuildInParallel", "True" } // guessed at this, doesn't seem to have an effect
};
var targets = new string[] { target };
var buildRequestData = new BuildRequestData(projectFileName, globalProperties, "15.0", targets, null);
BuildManager.DefaultBuildManager.ResetCaches();
var buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequestData);