Microsoft.Build.BuildEngine.Engine.BuildProjectFile C# (CSharp) Method

BuildProjectFile() public method

public BuildProjectFile ( string projectFile, string targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, IDictionary targetOutputs, BuildSettings buildFlags, string toolsVersion ) : bool
projectFile string
targetNames string
globalProperties Microsoft.Build.BuildEngine.BuildPropertyGroup
targetOutputs IDictionary
buildFlags BuildSettings
toolsVersion string
return bool
		public bool BuildProjectFile (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;
				}
			}
		}

Same methods

Engine::BuildProjectFile ( string projectFile ) : bool
Engine::BuildProjectFile ( string projectFile, string targetName ) : bool
Engine::BuildProjectFile ( string projectFile, string targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties ) : bool
Engine::BuildProjectFile ( string projectFile, string targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, IDictionary targetOutputs ) : bool
Engine::BuildProjectFile ( string projectFile, string targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, IDictionary targetOutputs, BuildSettings buildFlags ) : bool

Usage Example

Example #1
0
 public bool BuildProjectFile(string projectFileName,
                              string[] targetNames,
                              IDictionary globalProperties,
                              IDictionary targetOutputs, string toolsVersion)
 {
     if (String.IsNullOrEmpty(projectFileName))
     {
         project.ToolsVersion = toolsVersion;
         return(engine.BuildProject(project, targetNames, targetOutputs,
                                    BuildSettings.DoNotResetPreviouslyBuiltTargets));
     }
     else
     {
         BuildPropertyGroup bpg = new BuildPropertyGroup();
         if (globalProperties != null)
         {
             foreach (DictionaryEntry de in globalProperties)
             {
                 bpg.AddProperty(new BuildProperty(
                                     (string)de.Key, (string)de.Value,
                                     PropertyType.Global));
             }
         }
         return(engine.BuildProjectFile(projectFileName,
                                        targetNames, bpg, targetOutputs, BuildSettings.DoNotResetPreviouslyBuiltTargets, toolsVersion));
     }
 }
All Usage Examples Of Microsoft.Build.BuildEngine.Engine::BuildProjectFile