+ } catch (Exception e) {
+ this.LogError (projectFile, e.Message);
+ this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, e.ToString ()));
+ return false;
+ } finally {
+ EndEngineBuild (result);
+ }
+ }
+
+ bool BuildProjectFileInternal (string projectFile,
+ string[] targetNames,
+ BuildPropertyGroup globalProperties,
+ IDictionary targetOutputs,
+ BuildSettings buildFlags, string toolsVersion)
+ {
+
+ if ((buildFlags & BuildSettings.DoNotResetPreviouslyBuiltTargets) != BuildSettings.DoNotResetPreviouslyBuiltTargets)
+ builtTargetsOutputByName.Clear ();
+
+ Project project;
+
+ bool newProject = false;
+ if (!projects.TryGetValue (projectFile, out project)) {
+ project = CreateNewProject ();
+ newProject = true;
+ }
+
+ BuildPropertyGroup engine_old_grp = null;
+ BuildPropertyGroup project_old_grp = null;
+ if (globalProperties != null) {
+ engine_old_grp = GlobalProperties.Clone (true);
+ project_old_grp = project.GlobalProperties.Clone (true);
+
+ // Override project's global properties with the
+ // ones explicitlcur_y specified here
+ foreach (BuildProperty bp in globalProperties)
+ project.GlobalProperties.AddProperty (bp);
+
+ if (!newProject)
+ project.NeedToReevaluate ();
+ }
+
+ if (newProject)
+ project.Load (projectFile);
+
+ try {
+ string oldProjectToolsVersion = project.ToolsVersion;
+ if (String.IsNullOrEmpty (toolsVersion) && defaultToolsVersion != null)
+ // no tv specified, let the project inherit it from the
+ // engine. 'defaultToolsVersion' will be effective only
+ // it has been overridden. Otherwise, the project's own
+ // tv will be used.
+ project.ToolsVersion = defaultToolsVersion;
+ else
+ project.ToolsVersion = toolsVersion;
+
+ try {
+ return project.Build (targetNames, targetOutputs, buildFlags);
+ } finally {
+ project.ToolsVersion = oldProjectToolsVersion;
+ }
+ } finally {
+ if (globalProperties != null) {
+ GlobalProperties = engine_old_grp;
+ project.GlobalProperties = project_old_grp;
+ }
+ }