Project 类

定义

警告

此 API 现已过时。

表示可以使用 MSBuild 生成的项目。Represents a project that can be built using MSBuild.

public ref 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
Public Class Project
继承
Project
属性

注解

一个 Project 表示 MSBuildMSBuild 项目。A Project represents an MSBuildMSBuild project. 它是项、属性和目标的容器。It is a container for items, properties and targets. 它可以从内存中 XML 或 XML 文件加载项目内容,并且可以保存到 XML 文件中,同时保留大多数空白和所有 XML 注释。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.

每个 Project 都必须与 Engine 相关联才能访问共享信息。Every Project must be associated with an Engine to access shared information. 在生成过程中,Engine 对象将跟踪当前正在生成的项目。During a build, the Engine object keeps track of which projects are currently building.

构造函数

Project()

初始化 Project 类的新实例。Initializes a new instance of the Project class.

Project(Engine)

使用提供的 Project 初始化 Engine 类的新实例。Initializes a new instance of the Project class using the supplied Engine.

Project(Engine, String)

使用提供的 ProjectEngine 初始化 ToolsVersion 类的新实例。Initializes a new instance of the Project class using the supplied Engine and ToolsVersion.

属性

BuildEnabled

获取或设置一个值,该值指示是否允许为项目生成任务和目标。Gets or sets a value indicating whether the project is enabled for building tasks and targets.

DefaultTargets

获取或设置 MSBuildMSBuild 项目中 Project 元素的 DefaultTargets 属性。Gets or sets the DefaultTargets attribute of the Project element in the MSBuildMSBuild project.

DefaultToolsVersion

获取或设置在项目文件中的 Project 元素上找到的 ToolsVersion XML 特性。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

获取项目中所有项的集合,甚至包括那些由于 Condition 特性计算结果为 false 而不在生成过程中使用的项。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

获取项目文件是否具有 ToolsVersion XML 特性。Gets whether the Project file has the ToolsVersion XML attribute.

Imports

获取导入该项目中的项目。Gets the projects imported into this project.

InitialTargets

获取或设置 MSBuildMSBuild 项目中 Project 元素的 InitialTargets 属性。Gets or sets the InitialTargets attribute of the Project element in the MSBuildMSBuild 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

获取使用项目中的 ItemGroup 元素指定的项组的集合。Gets a collection of the item groups specified with the ItemGroup element in the project.

ParentEngine

获取生成项目的 EngineGets the Engine that builds the project.

PropertyGroups

获取使用项目中的 PropertyGroup 元素指定的属性组的集合。Gets a collection of the property groups specified with the PropertyGroup element in the project.

SchemaFile

获取或设置验证项目时使用的 XML 架构文件。Gets or sets the XML schema file to use when validating the project.

Targets

获取项目中的目标。Gets the targets in the project.

TimeOfLastDirty

获取一个 DateTime 对象,该对象指示上一次更改项目以至于需要将项目保存到文件的时间。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

获取项目中 UsingTask 元素的集合。Gets a collection of the UsingTask elements in the project.

Xml

获取表示项目的 XML。Gets the XML representing the project.

方法

AddNewImport(String, String)

Import 元素添加到项目末尾。Adds an Import element to the end of the project.

AddNewItem(String, String)

将指定的 Item 元素添加到项目。Adds the specified Item element to the project.

AddNewItem(String, String, Boolean)

将指定的 Item 元素添加到项目。Adds the specified Item element to the project.

AddNewItemGroup()

将新的 ItemGroup 元素添加到项目。Adds a new ItemGroup element to the project.

AddNewPropertyGroup(Boolean)

将新的 PropertyGroup 元素添加到项目。Adds a new PropertyGroup element to the project.

AddNewUsingTaskFromAssemblyFile(String, String)

使用指定的程序集文件添加新的 UsingTask 元素。Adds a new UsingTask element with the specified assembly file.

AddNewUsingTaskFromAssemblyName(String, String)

使用指定的程序集名称添加新的 UsingTask 元素。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.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
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.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetProjectExtensions(String)

ProjectExtensions 元素中的指定元素返回 XML 字符串值。Returns a string value of the XML from the specified element in the ProjectExtensions element.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Load(String)

将指定项目文件的内容加载到 Project 对象中。Loads the contents of the specified project file into the Project object.

Load(String, ProjectLoadSettings)

从磁盘上的项目 XML 文件读取此项目的内容。Reads the contents of this project from a project XML file on disk.

Load(TextReader)

将指定 TextReader 的内容加载到 Project 对象中。Loads the contents of the specified TextReader into the Project object.

Load(TextReader, ProjectLoadSettings)

从一个包含 XML 内容的字符串读取此项目的内容。Reads the contents of this project from a string containing the XML contents.

LoadXml(String)

将指定字符串的内容加载到 Project 对象中。Loads the contents of the specified string into the Project object.

LoadXml(String, ProjectLoadSettings)

从一个包含 XML 内容的字符串读取此项目的内容。Reads the contents of this project from a string containing the XML contents.

MarkProjectAsDirty()

将项目的 IsDirty 属性设置为 trueSets the IsDirty property of the project to true.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
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)

从项目中删除具有指定 condition 的所有项组,但不会修改已导入的项目。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)

从项目中删除具有指定 condition 的所有属性组,但不修改已导入的项目。Removes all property groups with the specified condition from the project, but does not modify imported projects.

RemovePropertyGroupsWithMatchingCondition(String, Boolean)

从主要项目文件中删除具有特定“Condition”的所有 <PropertyGroup>。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)

将项目保存在指定的 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)

使用指定的元素名称和内容设置项目的 ProjectExtensions 元素。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.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于