Project 类

定义

表示具有设计时语义的项目。Represents a project with design time semantics. 此类可加载项目文件、编辑项和属性,并可生成项目。This class can load project files, edit items and properties and build projects.

public ref class Project
public class Project
type Project = class
Public Class Project
继承
Project

构造函数

Project()

使用全局项目集合的全局属性和默认工具版本构造一个空项目。Constructs an empty project using the global project collection global properties and default tools version.

Project(IDictionary<String,String>, String, ProjectCollection)

使用给定的项目集合以及给定的全局属性和给定的工具版本,构造一个要进行计算的空项目。Constructs an empty project, to be evaluated with the given project collection and with the given global properties and given tools version.

Project(ProjectCollection)

使用给定项目集合的全局属性和默认工具版本构造一个空项目。Constructs an empty project using the given project collection global properties and default tools version.

Project(ProjectRootElement)

使用给定的项目根和全局项目集合的全局属性以及默认工具版本,构造一个空项目并对其进行计算。Constructs an empty project and evaluates it using the given project root and the global project collection global properties and default tools version.

Project(ProjectRootElement, IDictionary<String,String>, String)

使用给定的项目根以及给定的全局属性和给定的工具版本,构造一个空项目并对其进行计算。Constructs an empty project and evaluates it using the given project root and with the given global properties and given tools version.

Project(ProjectRootElement, IDictionary<String,String>, String, ProjectCollection)

使用给定的项目根以及给定的全局属性和给定的工具版本,构造一个项目并对其进行计算。Constructs a project and evaluates it using the given project root and with the given global properties and given tools version.

Project(ProjectRootElement, IDictionary<String,String>, String, ProjectCollection, ProjectLoadSettings)

使用给定的项目根以及给定的全局属性、给定的工具版本和给定的加载设置,构造一个空项目并对其进行计算。Constructs a project and evaluates it using the given project root and with the given global properties, given tools version, and given load settings.

Project(ProjectRootElement, IDictionary<String,String>, String, String, ProjectCollection, ProjectLoadSettings)

使用给定的项目根以及给定的全局属性、工具和子工具集版本、项目集合、和加载设置,构造一个项目并对其进行计算。Constructs a project and evaluates it using the given project root and with the given global properties, tools and sub-toolset versions, project collection, and load settings.

Project(String)

利用给定的源项目文件以及全局项目集合的全局属性和默认工具版本,构造一个项目并对其进行计算。Constructs a project and evaluates it from the given source project file and with the global project collection global properties and default tools version.

Project(String, IDictionary<String,String>, String)

利用给定的源项目文件以及给定的全局属性和给定的工具版本,构造一个项目并对其进行计算。Constructs a project and evaluates it from the given source project file and with the given global properties and given tools version.

Project(String, IDictionary<String,String>, String, ProjectCollection)

利用给定的源项目文件以及给定的全局属性和给定的工具版本,构造一个项目并对其进行计算。Constructs a project and evaluates it from the given source project file and with the given global properties and given tools version.

Project(String, IDictionary<String,String>, String, ProjectCollection, ProjectLoadSettings)

利用给定的源项目文件以及给定的全局属性、给定的工具版本和给定的加载设置,构造一个项目并对其进行计算。Constructs a project and evaluates it from the given source project file and with the given global properties, given tools version, and given load settings.

Project(String, IDictionary<String,String>, String, String, ProjectCollection, ProjectLoadSettings)

利用给定的源项目文件以及给定的全局属性、工具和子工具集版本、项目集合、和加载设置,构造一个项目并对其进行计算。Constructs a project and evaluates it from the given source project file and with the given global properties, tools and sub-toolset versions, project collection, and load settings.

Project(XmlReader)

构造一个项目,并计算来自给定的 XML 读取器的源代码。Constructs a project and evaluates the source code from the given XML reader. 将使用全局项目集合的全局属性和默认工具版本计算源代码。The source code is evaluated with the global project collection global properties and default tools version.

Project(XmlReader, IDictionary<String,String>, String)

构造一个项目,并计算来自给定的 XML 读取器的源代码。Constructs a project and evaluates the source code from the given XML reader. 将使用给定的全局属性和给定的工具版本计算源代码。The source code is evaluated with the given global properties and given tools version.

Project(XmlReader, IDictionary<String,String>, String, ProjectCollection)

构造一个项目,并计算来自给定的 XML 读取器的源代码。Constructs a project and evaluates the source code from the given XML reader. 将使用给定的全局属性和给定的工具版本计算源代码。The source code is evaluated with the given global properties and given tools version.

Project(XmlReader, IDictionary<String,String>, String, ProjectCollection, ProjectLoadSettings)

构造一个项目,并计算来自给定的 XML 读取器的源代码。Constructs a project and evaluates the source code from the given XML reader. 将使用给定的全局属性和给定的工具版本计算源代码。The source code is evaluated with the given global properties and given tools version.

Project(XmlReader, IDictionary<String,String>, String, String, ProjectCollection, ProjectLoadSettings)

构造一个项目,并计算来自给定的 XML 读取器的源代码。Constructs a project and evaluates the source code from the given XML reader. 使用给定全局属性、工具和子工具集版本、项目集合和加载设置来计算源代码。The source code is evaluated with the given global properties, tools and sub-toolset versions, project collection, and load settings.

属性

AllEvaluatedItemDefinitionMetadata

获取在计算过程中遇到的所有项定义元数据。Gets all item definition metadata encountered during evaluation.

AllEvaluatedItems

获取可枚举在计算过程中遇到的所有项的枚举器。Gets an enumerator over all items encountered during evaluation. 在进行第三轮计算时读取这些项。These are read during the third evaluation pass.

AllEvaluatedProperties

获取在计算过程中遇到的所有属性。Gets all properties encountered during evaluation.

ConditionedProperties

获取某些属性的可能值的集合,这些属性用于计算有关属性、属性组、导入和时间的条件。Gets a collection of possible property values for properties used to evaluate conditions found on properties, property groups, imports, and whens.

DirectoryPath

获取此项目的根目录。Gets the root directory for this project.

DisableMarkDirty

获取或设置一个值,此值指示是否已暂时禁用了 MarkDirty()Gets or sets a value that indicates whether MarkDirty() is temporarily disabled. 例如,可以通过此标记来设置全局属性,而不必将项目标记为已更新(从而导致重新计算)。This allows, for example, a global property to be set without the project getting marked dirty for reevaluation as a consequence.

EvaluationCounter

获取一个数值,在每次重新计算项目时,该数值会递增。Gets a number that is incremented every time that project is re-evaluated.

FullPath

获取或设置项目源文件的完整路径。Gets or sets the full path to the project source file.

GlobalProperties

获取用于计算此项目的全局属性的字典。Gets a dictionary of the global properties used for the evaluation of this project.

Imports

获取参与此项目计算的所有文件的列表。Gets a list of all the files that contributed to the evaluation of this project.

ImportsIncludingDuplicates

获取重复导入的列表(如果多次导入某个导入文件)。Gets a list of duplicate imports if an import was imported multiple times. 但是,在计算中仅使用第一个导入。However, only the first import was used in evaluation.

IsBuildEnabled

获取或设置一个属性,该属性选择是否可以生成此项目的目标和任务。Gets or sets a property that selects whether the targets and tasks of this project can be built.

IsDirty

获取一个值,此值指示此项目是否已经过了修改以致于必须要重新计算。Gets a value that indicates whether this project has been modified so that it must be reevaluated.

ItemDefinitions

获取此项目中的项定义的字典(按项类型组织条目)。Gets a dictionary of item definitions in this project, keyed by item type.

Items

获取可枚举此项目中的所有项(在项类型组中排序)的枚举器。Gets an enumerator over all items in this project, ordered within groups of item types.

ItemsIgnoringCondition

获取可枚举此项目中的所有项(在项类型组中排序)的枚举器。Gets an enumerator over all items in this project, ordered within groups of item types.

ItemTypes

获取可枚举此项目中的所有项类型的枚举器。Gets an enumerator over all item types in this project.

ProjectCollection

获取包含此项目的项目集合。Gets the project collection which contains this project.

ProjectFileLocation

给定文件的位置,其中没有任何特定内容。The location of the originating file itself, not any specific content within it. 如果未对文件命名一个名称,此为空的位置。If the file has not been given a name, this is an empty location. 这是没有位置的合理情况。This is a legitimate case of having no location.

Properties

获取可枚举此项目中的所有属性的枚举器。Gets an enumerator over all properties in this project. 这是一个无序集合。This is an unordered collection.

SkipEvaluation

获取或设置一个值,此值指示是否已暂时禁用了 ReevaluateIfNecessary。Gets or sets a value that indicates whether ReevaluateIfNecessary is temporarily disabled. 当宿主希望对项目进行大量读写操作并希望临时牺牲准确性以换取性能,则可以使用此标志。This is useful when the host expects to make a number of reads and writes to the project, and wants to temporarily sacrifice correctness for performance.

SubToolsetVersion

获取 SubToolsetVersion 特性的值(如果有的话)。Gets the value of the SubToolsetVersion attribute, if any. 此值结合 TolsVersion 特性的值确定此项目的工具集属性。This value was combined with the value of the ToolsVersion attribute to determine the toolset properties for this project.

Targets

获取此项目中的所有目标的字典(按目标名称组织条目)。Gets a dictionary of all targets in this project, keyed by target name.

ToolsVersion

获取计算此项目所使用的工具版本(如果有的话)。Gets the tools version that this project was evaluated with, if any.

Xml

获取与此项目关联的根目录。Gets the root project associated with this project. 绝不会为 nullCan never be null.

方法

AddItem(String, String)

向项目中添加不包含元数据的项。Adds an item with no metadata to the project.

AddItem(String, String, IEnumerable<KeyValuePair<String,String>>)

向项目中添加包含给定元数据的项。Adds an item with the given metadata to the project.

AddItemFast(String, String)

向项目中添加不包含元数据的项。Adds an item with no metadata to the project. 将不会尝试查看现有的通配符是否已匹配新项,除非它是项组中的第一项。Makes no effort to see if an existing wildcard would already match the new item, unless it is the first item in an item group. 也不会尝试将新项放置到相似项的附近。Makes no effort to locate the new item near similar items.

AddItemFast(String, String, IEnumerable<KeyValuePair<String,String>>)

向此项目中添加包含元数据的项。Adds an item with metadata to the project. 元数据可能为 null,以指示没有元数据。Metadata may be null, indicating no metadata. 将不会尝试查看现有的通配符是否已匹配新项,除非它是项组中的第一项。Makes no effort to see if an existing wildcard would already match the new item, unless it is the first item in an item group. 也不会尝试将新项放置到相似项的附近。Makes no effort to locate the new item near similar items.

Build()

使用默认目标生成此项目。Builds this project, using the default targets.

Build(IEnumerable<ILogger>)

使用默认目标和给定记录器生成此项目。Builds this project, using the default targets and the given loggers.

Build(IEnumerable<ILogger>, IEnumerable<ForwardingLoggerRecord>)

使用默认目标以及给定记录器和远程记录器生成此项目。Builds this project, using the default targets and the given loggers and remote loggers.

Build(ILogger)

使用默认目标和给定记录器生成此项目。Builds this project, using the default targets and the given logger.

Build(String)

生成此项目(生成给定目标)。Builds this project, building the given target.

Build(String, IEnumerable<ILogger>)

生成此项目(生成给定目标并使用给定记录器)。Builds this project, building the given target and using the given loggers.

Build(String, IEnumerable<ILogger>, IEnumerable<ForwardingLoggerRecord>)

生成此项目(生成给定目标并使用给定记录器和远程记录器)。Builds this project, building the given target and using the given loggers and remote loggers.

Build(String[])

生成此项目(生成给定目标)。Builds this project, building the given targets.

Build(String[], IEnumerable<ILogger>)

生成此项目(生成给定目标并使用给定记录器)。Builds this project, building the given targets and using the given loggers.

Build(String[], IEnumerable<ILogger>, IEnumerable<ForwardingLoggerRecord>)

生成此项目(生成给定目标并使用给定记录器和远程记录器)。Builds this project, building the given targets and using the given loggers and remote loggers.

CreateProjectInstance()

基于此项目创建一个项目实例,但将此项目与创建的项目实例完全断开连接。Creates a project instance based on this project, but completely disconnected from it.

CreateProjectInstance(ProjectInstanceSettings)

基于此项目创建一个项目实例,但将此项目与创建的项目实例完全断开连接。Creates a project instance based on this project, but completely disconnected from it.

Equals(Object)

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

(继承自 Object)
ExpandString(String)

通过扩展项和属性,计算给定的字符串。Evaluates the given string by expanding items and properties. 计算字符串时将其视为位于项目文件的最末尾。The string is evaluated as if it were found at the very end of the project file.

GetEvaluatedItemIncludeEscaped(ProjectItem)

获取所提供的项的 Include 特性的值,该值是计算得到的且经过了转义。Gets evaluated, escaped value of the Include attribute of the provided items.

GetEvaluatedItemIncludeEscaped(ProjectItemDefinition)

获取所提供的项定义的 Include 特性的值,该值是计算得到的且经过了转义。Gets the evaluated, escaped value of the Include attribute of the provided item definition.

GetHashCode()

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

(继承自 Object)
GetItems(String)

获取项目中的给定项类型的所有项。Gets all the items in the project of the given item type. 如果不存在任何给定项类型的项,则返回一个空列表。If there are none, returns an empty list. 使用 AddItem 或 RemoveItem 修改此项目中的项。Use AddItem or RemoveItem to modify items in this project.

GetItemsByEvaluatedInclude(String)

获取具有给定的计算 Include 特性的所有项。Gets all items that have the given evaluated Include attribute.

GetItemsIgnoringCondition(String)

获取项目中的给定类型的所有项(不管其 Condition 特性的计算结果是否为 true)。Gets all the items in the project of the given type, whether or not their Condition attribute evaluates to true. 这是一个只读列表:可使用 AddItem 或 RemoveItem 修改此项目中的项。This is a read-only list: use AddItem or RemoveItem to modify items in this project.

GetLogicalProject()

获取可枚举“逻辑项目”中的所有元素的枚举器。Gets an enumerator over all the elements in the "logical project". 逻辑项目定义为从单个 MSBuild 文件获得的未计算项目,该 MSBuild 文件是通过将原始 MSBuild 项目清单文件的所有导入的文本内联得到的。The logical project is defined as the unevaluated project obtained from the single MSBuild file that is the result of inlining the text of all imports of the original MSBuild project manifest file.

GetMetadataValueEscaped(ProjectItem, String)

获取所提供的项中具有提供的名称的元数据的转义值。Gets the escaped value of the metadatum with the provided name on the provided item.

GetMetadataValueEscaped(ProjectItemDefinition, String)

获取所提供的项定义上具有提供的名称的元数据的转义值。Gets the escaped value of the metadatum with the provided name on the provided item definition.

GetMetadataValueEscaped(ProjectMetadata)

获取所提供的元数据的转义值。Gets the escaped value of the provided metadatum.

GetProperty(String)

获取项目中具有指定名称的任何属性。Gets any property in the project that has the specified name.

GetPropertyValue(String)

获取此项目中的给定属性的值。Gets the value of the given property in this project.

GetPropertyValueEscaped(ProjectProperty)

获取所提供的属性的转义值。Gets the escaped value of the provided property.

GetType()

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

(继承自 Object)
MarkDirty()

将此项目标记为已修改。Marks this project as modified.

MemberwiseClone()

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

(继承自 Object)
ReevaluateIfNecessary()

重新计算项目以合并任何更改。Reevaluates the project to incorporate any changes.

RemoveGlobalProperty(String)

移除一个全局属性,并将项目标记为已修改。Removes a global property and marks the project as modified.

RemoveItem(ProjectItem)

从项目中移除一个项。Removes an item from the project. 要移除的项必须存在于项目中,并且不得源自于导入的文件。The item to be removed must be present in the project, and must not originate from an imported file.

RemoveItems(IEnumerable<ProjectItem>)

移除项目中的所有给定项,除非它们源自于导入的项目。Removes all the given items from the project, unless they originate from an imported project.

RemoveProperty(ProjectProperty)

从项目中移除一个属性。Removes an property from the project. 要移除的属性必须存在于项目中,并且不得源自于导入的文件。The property to be removed must be present in the project, and must not originate from an imported file.

Save()

使用默认的字符编码将项目保存到文件系统上(如果项目已修改)。Saves the project to the file system, if modified, using the default character encoding.

Save(Encoding)

使用给定的字符编码将项目保存到文件系统上(如果项目已修改)。Saves the project to the file system, if modified, using the given character encoding.

Save(String)

使用默认的字符编码将项目保存到文件系统上(如果项目已修改或项目源代码的路径已修改)。Saves the project to the file system, if modified or if the path to the project source code changes, using the default character encoding.

Save(String, Encoding)

使用给定的字符编码将项目保存到文件系统上(如果项目已修改或项目源代码的路径已修改)。Saves the project to the file system, if modified or if the path to the project source code changes, using the given character encoding.

Save(TextWriter)

将项目保存到提供的文本编写器(无论项目是否已修改)。Saves the project to the provided text writer, whether or not the project has been modified. 使用文本编写器的字符编码,并将项目标记为未修改。Uses the character encoding of the text writer and marks the project as unmodified.

SaveLogicalProject(TextWriter)

保存“逻辑”或“预处理”项目文件,该文件包括所有导入的文件,就如同这些文件构成了单个文件一样。Saves a "logical" or "preprocessed" project file, that includes all the imported files as if they formed a single file.

SetGlobalProperty(String, String)

在计算项目之后设置一个全局属性。Sets a global property after the project has been evaluated. 如果值发生更改,则将项目标记为需要重新计算。If the value changes, the project is marked to require reevaluation.

SetProperty(String, String)

在项目中设置或添加一个具有给定名称和值的属性。Sets or adds a property with the given name and value to the project. 如果存在同名属性,但它不是源自于导入的文件,则覆盖该属性的值。Overwrites the value of a property with the same name if it did not originate in an imported file.

ToString()

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

(继承自 Object)

适用于