Project Class

Definition

Caution

This class has been deprecated. Please use Microsoft.Build.Evaluation.Project from the Microsoft.Build assembly instead.

Represents a project that can be built using MSBuild.

public ref class Project
public class Project
[System.Obsolete("This class has been deprecated. Please use Microsoft.Build.Evaluation.Project from the Microsoft.Build assembly instead.")]
public class Project
type Project = class
[<System.Obsolete("This class has been deprecated. Please use Microsoft.Build.Evaluation.Project from the Microsoft.Build assembly instead.")>]
type Project = class
Public Class Project
Inheritance
Project
Attributes

Remarks

A Project represents an MSBuild project. It is a container for items, properties and targets. It can load project content from in-memory XML or from an XML file, and can save to an XML file, preserving most white space and all XML comments.

Every Project must be associated with an Engine to access shared information. During a build, the Engine object keeps track of which projects are currently building.

Constructors

Project()

Initializes a new instance of the Project class.

Project(Engine)

Initializes a new instance of the Project class using the supplied Engine.

Project(Engine, String)

Initializes a new instance of the Project class using the supplied Engine and ToolsVersion.

Properties

BuildEnabled

Gets or sets a value indicating whether the project is enabled for building tasks and targets.

DefaultTargets

Gets or sets the DefaultTargets attribute of the Project element in the MSBuild project.

DefaultToolsVersion

Gets or sets the ToolsVersion XML attribute found on the Project element in the project file.

Encoding

Gets the encoding for the project file.

EvaluatedItems

Gets a collection of the items evaluated during the build.

EvaluatedItemsIgnoringCondition

Gets a collection of all items in a project, even those not used in the build process because a Condition attribute evaluated to false.

EvaluatedProperties

Gets a collection of the properties evaluated during the build.

FullFileName

Gets or sets the fully qualified path and file name of the project file.

GlobalProperties

Gets or sets a collection of the global properties for the project.

HasToolsVersionAttribute

Gets whether the Project file has the ToolsVersion XML attribute.

Imports

Gets the projects imported into this project.

InitialTargets

Gets or sets the InitialTargets attribute of the Project element in the MSBuild project.

IsDirty

Gets a value indicating whether the project has changed and needs to be saved to a file.

IsValidated

Gets a value indicating whether the project is to be validated against a schema.

ItemGroups

Gets a collection of the item groups specified with the ItemGroup element in the project.

ParentEngine

Gets the Engine that builds the project.

PropertyGroups

Gets a collection of the property groups specified with the PropertyGroup element in the project.

SchemaFile

Gets or sets the XML schema file to use when validating the project.

Targets

Gets the targets in the project.

TimeOfLastDirty

Gets a DateTime object indicating the time the project was last changed in a way that required it to be saved to a file.

ToolsVersion

Gets or sets the current version of the Toolset being used by the project.

UsingTasks

Gets a collection of the UsingTask elements in the project.

Xml

Gets the XML representing the project.

Methods

AddNewImport(String, String)

Adds an Import element to the end of the project.

AddNewItem(String, String)

Adds the specified Item element to the project.

AddNewItem(String, String, Boolean)

Adds the specified Item element to the project.

AddNewItemGroup()

Adds a new ItemGroup element to the project.

AddNewPropertyGroup(Boolean)

Adds a new PropertyGroup element to the project.

AddNewUsingTaskFromAssemblyFile(String, String)

Adds a new UsingTask element with the specified assembly file.

AddNewUsingTaskFromAssemblyName(String, String)

Adds a new UsingTask element with the specified assembly name.

Build()

Builds the default targets of the project.

Build(String)

Builds the specified target in the project.

Build(String[])

Builds the specified list of targets in the project.

Build(String[], IDictionary)

Builds the specified list of targets in the project, and returns the outputs of the targets.

Build(String[], IDictionary, BuildSettings)

Builds the specified list of targets in the project using the specified settings, and returns the outputs of the targets.

GetConditionedPropertyValues(String)

Returns a list of possible values for the specified property.

GetEvaluatedItemsByName(String)

Returns all evaluated items belonging to the specified item collection.

GetEvaluatedItemsByNameIgnoringCondition(String)

Returns all items belonging to the specified item collection.

GetEvaluatedProperty(String)

Returns the value of the specified property.

GetProjectExtensions(String)

Returns a string value of the XML from the specified element in the ProjectExtensions element.

Load(String)

Loads the contents of the specified project file into the Project object.

Load(String, ProjectLoadSettings)

Reads the contents of this project from a project XML file on disk.

Load(TextReader)

Loads the contents of the specified TextReader into the Project object.

Load(TextReader, ProjectLoadSettings)

Reads the contents of this project from a string containing the XML contents.

LoadXml(String)

Loads the contents of the specified string into the Project object.

LoadXml(String, ProjectLoadSettings)

Reads the contents of this project from a string containing the XML contents.

MarkProjectAsDirty()

Sets the IsDirty property of the project to true.

RemoveAllItemGroups()

Removes all item groups from the project, but does not modify imported projects.

RemoveAllPropertyGroups()

Removes all property groups from the project, but does not modify imported projects.

RemoveImportedPropertyGroup(BuildPropertyGroup)

Removes the specified property group from the main project file.

RemoveItem(BuildItem)

Removes the specified item from the project.

RemoveItemGroup(BuildItemGroup)

Removes the specified item group from the project.

RemoveItemGroupsWithMatchingCondition(String)

Removes all item groups with the specified condition from the project, but does not modify imported projects.

RemoveItemsByName(String)

Removes all items in the specified item collection from the project, but does not modify imported projects.

RemovePropertyGroup(BuildPropertyGroup)

Removes the specified property group from the project.

RemovePropertyGroupsWithMatchingCondition(String)

Removes all property groups with the specified condition from the project, but does not modify imported projects.

RemovePropertyGroupsWithMatchingCondition(String, Boolean)

Removes all <PropertyGroup>'s from the main project file that have a specific "Condition."

ResetBuildStatus()

Resets the status every target in the project so that the next build will build all targets again.

Save(String)

Saves the project to the specified file.

Save(String, Encoding)

Saves the project in the specified file with the specified encoding.

Save(TextWriter)

Saves the project in the specified TextWriter object.

SetImportedProperty(String, String, String, Project)

Sets the value of a property in the specified imported project.

SetImportedProperty(String, String, String, Project, PropertyPosition)

Sets the value of a property in the specified imported project.

SetImportedProperty(String, String, String, Project, PropertyPosition, Boolean)

Sets the value of a property in the specified imported project.

SetProjectExtensions(String, String)

Sets the ProjectExtensions element of the project with the specified element name and content.

SetProperty(String, String)

Sets the value of the specified property.

SetProperty(String, String, String)

Sets the value of the specified property.

SetProperty(String, String, String, PropertyPosition)

Sets the value of the specified property.

SetProperty(String, String, String, PropertyPosition, Boolean)

Sets the value of the specified property.

Applies to