ProjectCollection 类

定义

封装一组相关项目及其工具集、默认的全局属性集以及生成这些项目应使用的记录器。Encapsulates a set of related projects, their toolsets, a default set of global properties, and the loggers that should be used to build them. 此类的一个全局版本将用作默认的项目集合。A global version of this class acts as the default project collection.

public ref class ProjectCollection : IDisposable
public class ProjectCollection : IDisposable
type ProjectCollection = class
    interface IDisposable
Public Class ProjectCollection
Implements IDisposable
继承
ProjectCollection
实现

注解

应用程序域中可以有多个项目集合。Multiple project collections can exist within an app domain. 但是,它们不能同时生成。However, these must not build concurrently.

构造函数

ProjectCollection()

创建一个没有全局属性或记录器的项目集合。Creates a project collection with no global properties or loggers. 将利用配置文件和注册表初始化项目集合工具集。The project collection toolset is initialized from the configuration file and registry.

ProjectCollection(IDictionary<String,String>)

实例化一个项目集合,该项目集合包含指定的全局属性但没有记录器,并从配置文件和注册表中读取工具集信息。Instantiates a project collection with specified global properties, no loggers, and that reads toolset information from the configuration file and registry.

ProjectCollection(IDictionary<String,String>, IEnumerable<ILogger>, IEnumerable<ForwardingLoggerRecord>, ToolsetDefinitionLocations, Int32, Boolean)

创建一个具有指定的全局属性、记录器、节点计数和 onlyLogCriticalEvents 值的项目集合。Creates a project collection with specified global properties, loggers, node count, and onlyLogCriticalEvents value. 将利用给定位置中的工具集初始化项目集合工具集。The project collection toolset is initialized from toolsets in the given locations.

ProjectCollection(IDictionary<String,String>, IEnumerable<ILogger>, ToolsetDefinitionLocations)

实例化一个项目集合,该项目集合包含指定的全局属性和记录器,并使用指定的工具集位置。Instantiates a project collection with specified global properties and loggers and using the specified toolset locations.

ProjectCollection(ToolsetDefinitionLocations)

创建一个没有全局属性或记录器的项目集合。Creates a project collection with no global properties or loggers. 将利用给定位置中的工具集初始化项目集合工具集。The project collection toolset is initialized from toolsets in the given locations.

属性

Count

获取当前加载到此集合中的项目的数量。Gets the number of projects currently loaded into this collection.

DefaultToolsVersion

获取此项目集合的默认工具版本。Gets the default tools version of this project collection.

DisableMarkDirty

获取或设置一个标志,该标志确定是否对此集合中的项目临时禁用 MarkDirty()Gets or sets a flag that determines whether MarkDirty() is temporarily disabled on projects in this collection. 例如,可以通过此标记来设置全局属性,而不必将项目标记为已更新(从而导致重新计算)。This allows, for example, a global properties to be set without projects getting marked dirty for reevaluation as a consequence.

GlobalProjectCollection

获取全局项目集合对象。Gets the global project collection object.

GlobalProperties

获取此集合中的所有项目的只读默认全局属性。Gets the read-only default global properties for all projects in this collection.

HostServices

获取或设置一个对象,在生成项目集合中包含的项目的过程中,该对象将为各个任务提供主机服务。Gets or sets an object that provides host services to tasks during builds of projects contained in the project collection.

IsBuildEnabled

获取或设置一个值,该值指示是否可构建项目集合中项目的目标和任务。Gets or sets a value that indicates whether the targets and tasks of projects in the project collection can be built.

LoadedProjects

获取当前加载到此集合中的所有项目。Gets all the projects currently loaded into this collection.

Loggers

获取此集合中的项目可用于其生成的所有记录器。Gets all loggers that projects in this collection can use for their builds.

OnlyLogCriticalEvents

获取或设置一个值,该值指示是否仅记录关键事件,例如警告和错误。Gets or sets a value that indicates whether only critical events such as warnings and errors are logged.

SkipEvaluation

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

ToolsetLocations

获取用于查找工具集的位置。Gets the locations used to find the toolsets.

Toolsets

获取可用于此项目集合的工具集。Gets the toolsets available to this project collection.

Version

获取包含 MSBuild 引擎的程序集文件的文件版本。Gets the file version of the assembly file that contains the MSBuild engine.

方法

AddToolset(Toolset)

向项目集合中添加新的工具集。Adds a new toolset to the project collection. 使用相同的工具版本替换任何现有工具集。Replaces any existing toolset with the same tools version.

ContainsToolset(String)

确定是否为给定的工具版本定义了工具集。Determines whether a toolset is defined for the given tools version.

Dispose()

释放托管资源和非托管资源。Releases both managed and unmanaged resources. 当主机不再需要该项目集合时调用。Called when a host no longer needs the project collection.

Dispose(Boolean)

释放托管资源和非托管资源。Releases both managed and unmanaged resources. 当主机不再需要该项目集合时调用。Called when a host no longer needs the project collection. 关闭该项目集合拥有的任何记录服务,并释放记录器线程。Shuts down any logging services that the project collection owns and releases the logger thread.

Equals(Object)

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

(继承自 Object)
Escape(String)

将字符串中的特殊字符转换为 MSBuild 转义格式。Converts special characters in a string to MSBuild escape format.

GetGlobalProperty(String)

获取该项目集合的任何具有指定名称的全局属性。Gets any global property on the project collection that has the specified name.

GetHashCode()

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

(继承自 Object)
GetLoadedProjects(String)

获取其项目路径与给定路径相匹配的所有项目。Gets all projects whose project path matches the given path.

GetToolset(String)

获取具有指定工具版本的工具集。Gets the toolset with the specified tools version.

GetType()

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

(继承自 Object)
LoadProject(String)

利用给定的项目文件中的源代码计算一个项目。Evaluates a project from the source code in the given project file. 将使用此项目集合的全局属性和工具版本来计算源代码。The source code is evaluated with the global properties and tools version of this project collection.

LoadProject(String, IDictionary<String,String>, String)

利用从给定的项目文件读取的源代码计算一个项目。Evaluates a project from the source code read from the given project file. 将使用给定的全局属性和工具版本计算源代码。The source code is evaluated with the given global properties and tools version.

LoadProject(String, String)

利用从给定的项目文件读取的源代码计算一个项目。Evaluates a project from the source code read from the given project file. 将使用此项目集合的全局属性和给定的工具版本来计算源代码。The source code is evaluated with the global properties of this project collection and the given tools version.

LoadProject(XmlReader)

利用从给定的 XML 读取器读取的源代码计算一个项目。Evaluates a project from the source code read from the given XML reader. 将使用此项目集合的全局属性和工具版本来计算源代码。The source code is evaluated with the global properties and tools version of this project collection.

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

利用从给定的 XML 读取器读取的源代码计算一个项目。Evaluates a project from the source code read from the given XML reader. 将使用给定的全局属性和工具版本计算源代码。The source code is evaluated with the given global properties and tools version.

LoadProject(XmlReader, String)

利用从给定的 XML 读取器读取的源代码计算一个项目。Evaluates a project from the source code read from the given XML reader. 将使用此项目集合的全局属性和给定的工具版本来计算源代码。The source code is evaluated with the global properties of this project collection and the given tools version.

MemberwiseClone()

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

(继承自 Object)
RegisterForwardingLoggers(IEnumerable<ForwardingLoggerRecord>)

向用于此集合中的项目生成的远程记录器的集合添加给定的远程记录器。Adds the given remote loggers to the collection of remote loggers used for builds of projects in this collection.

RegisterLogger(ILogger)

向用于此集合中的项目生成的记录器集合添加给定的记录器。Adds the given logger to the collection of loggers used for builds of projects in this collection.

RegisterLoggers(IEnumerable<ILogger>)

向用于此集合中的项目生成的记录器集合添加给定的记录器。Adds the given loggers to the collection of loggers used for builds of projects in this collection.

RemoveAllToolsets()

从项目集合中移除所有工具集。Removes all toolsets from the project collection.

RemoveGlobalProperty(String)

从默认全局属性集中移除一个全局属性。Removes a global property from the set of default global properties.

RemoveToolset(String)

从项目集合中移除一个工具集。Removes a toolset from the project collection.

SetGlobalProperty(String, String)

设置默认全局属性集中的一个属性的值。Sets the value of a property in the default set of global properties.

ToString()

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

(继承自 Object)
TryUnloadProject(ProjectRootElement)

从集合中移除项目的尝试。Attempts to remove a project from the collection.

Unescape(String)

将字符串中的转义字符转换为具有特殊意义的 MSBuild 字符。Converts escaped characters in a string to MSBuild characters with special meaning.

UnloadAllProjects()

移除此项目集合中的所有项目。Removes all projects in this project collection.

UnloadProject(Project)

从项目集合中移除给定的项目。Removes the given project from the project collection.

UnloadProject(ProjectRootElement)

从项目根缓存中移除项目根元素。Removes a project root element from the project root cache.

UnregisterAllLoggers()

移除由此集合中的项目生成使用的记录器集合中的所有记录器。Removes all loggers from the collection of loggers used by project builds in this collection.

事件

ProjectAdded

当项目添加到项目集合 ProjectRootElementCache 时的事件引发。Event that is fired when a project is added to the ProjectRootElementCache of this project collection.

ProjectChanged

当直接更改该事例包含的 Project 时引发。Raised when a Project contained by this instance is directly changed.

ProjectCollectionChanged

当该实例上的状态更改时引发。Raised when state is changed on this instance.

ProjectXmlChanged

当更改该事例包含的 ProjectRootElement 时引发。Raised when a ProjectRootElement contained by this instance is changed.

适用于