static Engine InitializeEngine (string slnFile)
{
var engine = new Engine ();
engine.DefaultToolsVersion = MSBuildConsts.Version;
var gp = engine.GlobalProperties;
//this causes build targets to behave how they should inside an IDE, instead of in a command-line process
gp.SetProperty ("BuildingInsideVisualStudio", "true");
//we don't have host compilers in MD, and this is set to true by some of the MS targets
//which causes it to always run the CoreCompile task if BuildingInsideVisualStudio is also
//true, because the VS in-process compiler would take care of the deps tracking
gp.SetProperty ("UseHostCompilerIfAvailable", "false");
if (string.IsNullOrEmpty (slnFile))
return engine;
gp.SetProperty ("SolutionPath", Path.GetFullPath (slnFile));
gp.SetProperty ("SolutionName", Path.GetFileNameWithoutExtension (slnFile));
gp.SetProperty ("SolutionFilename", Path.GetFileName (slnFile));
gp.SetProperty ("SolutionDir", Path.GetDirectoryName (slnFile) + Path.DirectorySeparatorChar);
return engine;
}