0

I have the following code for building a solution at solutionPath:

var properties = new Dictionary<string, string>();
properties["Configuration"] = buildType;
properties["Platform"] = "x86";

var request = new BuildRequestData(solutionPath, properties, null, new string[] { "Build" }, null);
var result = BuildManager.DefaultBuildManager.Build(parameters, request);

It works great, except if my project includes C# 6.0 features, I get errors. For example, the following:

throw new ArgumentException($"Could not find any registered events with the name {name}.");

Gives me the following:

Error Unexpected character '$'

Do I need to change some setting on my BuildManager or on the parameters? My app which is doing the building is targeting .NET 4.6 and is built by Visual Studio 2015.

svick
  • 236,525
  • 50
  • 385
  • 514
Victor Chelaru
  • 4,491
  • 3
  • 35
  • 49

1 Answers1

2

Looks like my project was referencing an old version of the relevant .dlls:

  • Microsoft.Build
  • Microsoft.Build.Engine
  • Microsoft.Build.Framework

More info here:

BuildManager to use another version of MSBuild

Community
  • 1
  • 1
Victor Chelaru
  • 4,491
  • 3
  • 35
  • 49