static ProjectCollection InitializeEngine (string slnFile)
{
var engine = new ProjectCollection ();
engine.DefaultToolsVersion = MSBuildConsts.Version;
//this causes build targets to behave how they should inside an IDE, instead of in a command-line process
engine.SetGlobalProperty ("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
engine.SetGlobalProperty ("UseHostCompilerIfAvailable", "false");
if (string.IsNullOrEmpty (slnFile))
return engine;
engine.SetGlobalProperty ("SolutionPath", Path.GetFullPath (slnFile));
engine.SetGlobalProperty ("SolutionName", Path.GetFileNameWithoutExtension (slnFile));
engine.SetGlobalProperty ("SolutionFilename", Path.GetFileName (slnFile));
engine.SetGlobalProperty ("SolutionDir", Path.GetDirectoryName (slnFile) + Path.DirectorySeparatorChar);
return engine;
}