I have a target project that uses c# 6.0 I need to programatically build it.
I have the code below:
var pc = new ProjectCollection();
pc.DefaultToolsVersion = "14.0" //set tools version
var globalProperty = new Dictionary<string, string>
{
{"Configuration", "Release"},
{"Platform", "Any CPU"},
{"OutputPath", Utils.GetGaugeBinDir()}
};
var buildRequestData = new BuildRequestData(solutionFullPath, globalProperty, "14.0", new[] {"Build"}, null); //Set tools version here as well
var errorCodeAggregator = new ErrorCodeAggregator();
var buildParameters = new BuildParameters(pc) {Loggers = new ILogger[] {consoleLogger, errorCodeAggregator}};
var buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequestData);
No matter where I set the tools version (of the two options above), it does not build C# 6.0.
On command line, I can do this:
msbuild foo.csproj /tv:14.0 /t:rebuild
I invoke this from MSBuild 12.0 bin directory, and it works. If I drop the /tv:14.0 flag, it fails as expected.
So, question is, what is the programatic way of specifying /tv flag to BuildManager ?