My dilemma is that I need to compile a large amount of projects and solutions as per the configuration settings specified in the files. I've found a few different ways to do this, and I've landed on using the Microsoft.Build.BuildEngine.Engine class, which has recently become deprecated.
Here's some sample code that illustrates its use: (note that node.Path is the path to the project file)
var builder = new Engine { BinPath = @"C:\Windows\Microsoft.NET\Framework\v3.5" };
var logger = new FileLogger { Parameters = @"logfile=" + Path.Combine(logdir, Path.GetFileName(node.Path)) + ".txt" };
compiler.RegisterLogger(logger);
bool success = compiler.BuildProjectFile(node.Path);
compiler.UnregisterAllLoggers();
return success;
My problem - it compiles in debug :(
Looking through the members of the class hasn't helped much as there aren't that many properties exposed. The one hint was the PropertyGroup property which seems to allow the setting of some project build options.. however it isn't clear how to get the resulting call to BuildProjectFile to output in release.
I'd really appreciate any help with this!