ProjectCollection.UnloadProject Method

Definition

Removes a project root element from the project root cache.

Overloads

UnloadProject(ProjectRootElement)

Unloads a project XML root element from the weak cache.

UnloadProject(Project)

Unloads the specific project specified. Host should call this when they are completely done with the project. If project was not already loaded, throws InvalidOperationException.

UnloadProject(ProjectRootElement)

Source:
ProjectCollection.cs

Unloads a project XML root element from the weak cache.

C#
public void UnloadProject(Microsoft.Build.Construction.ProjectRootElement projectRootElement);

Parameters

projectRootElement
ProjectRootElement

The project XML root element to unload.

Exceptions

Thrown if the project XML root element to unload is still in use by a loaded project or its imports.

Remarks

This method is useful for the case where the host knows that all projects using this XML element are unloaded, and desires to discard any unsaved changes.

Applies to

MSBuild 17 和其他版本
產品 版本
MSBuild 15, 16, 17
MSBuild (.NET Core) 15, 16, 17

UnloadProject(Project)

Source:
ProjectCollection.cs

Unloads the specific project specified. Host should call this when they are completely done with the project. If project was not already loaded, throws InvalidOperationException.

C#
public void UnloadProject(Microsoft.Build.Evaluation.Project project);

Parameters

project
Project

The project to remove.

Remarks

The host should call this method when it no longer needs the project.

Throws InvalidOperationException if the given project is not present in the project collection.

Applies to

MSBuild 17 和其他版本
產品 版本
MSBuild 15, 16, 17
MSBuild (.NET Core) 15, 16, 17