Microsoft.Build.Utilities 命名空间

提供可用于创建自己的 MSBuild 记录器和任务的帮助程序类。 Provides helper classes that you can use to create your own MSBuild loggers and tasks. 有关信息,请参阅 MSBuild For information, see MSBuild.


此类提供与 Task 类相同但派生自 MarshalByRefObject 的功能,以便可以在其自己的应用域中进行实例化。This class provides the same functionality as the Task class, but derives from MarshalByRefObject so that it can be instantiated in its own app domain.


包含 AssemblyFoldersEx 注册表项中有关项的信息。Contains information about entries in the AssemblyFoldersEx registry keys.


表示有关程序集文件夹的信息。Represents information about assembly folders.


此类是采用规范格式的 .read.This class is the filetracking log interpreter for .read. 跟踪日志或那些已经过根化处理 (^) 以变得规范的 .read. 跟踪日志的文件跟踪日志解释程序tracking logs in canonical form or those that have been rooted (^) to make them canonical


此类是 .write 的文件跟踪日志解释器。This class is the filetracking log interpreter for .write. 跟踪使用规范格式 Canonical .write 的日志。tracking logs in canonical form Canonical .write. 日志需要固定,因为输出需要与输入相关联。logs need to be rooted, since the outputs need to be associated with an input.


(1) 确保包含连字符的值 (RC 括起来至少需要此) (2) 转义任何嵌入的引号。(1) Make sure values containing hyphens are quoted (RC at least requires this) (2) Escape any embedded quotes. --应将文字双引号编写为 " ""--doublequotes 前的反斜杠必须成对。-- Literal double quotes should be written in the form " not "" -- Backslashes falling just before doublequotes must be doubled. --原义双引号只能成对出现 (无法传递单字面值双引号) --函数双引号 (例如,处理空间) 最好将名称和值放在开关中,如/Dname = value。-- Literal double quotes can only occur in pairs (you cannot pass a single literal double quote) -- Functional double quotes (for example to handle spaces) are best put around both name and value in switches like /Dname=value.


此类包含一些用于封装跟踪器的启动和记录的实用工具函数This class contains utility functions to encapsulate launching and logging for the Tracker


用于存储和询问由跟踪操作记录的输入和输出的类。Class used to store and interrogate inputs and outputs recorded by tracking operations.


此帮助程序基类为处理生成引擎引发的事件的记录器提供默认功能。This helper base class provides default functionality for loggers that handle events raised by the build engine. 此类只能以派生形式实例化。This class can only be instantiated in a derived form.


这是一个多路复用记录器。This is a multiplexing logger. 该记录器的作用是允许在生成期间注册和注销多个记录器。The purpose of this logger is to allow the registration and deregistration of multiple loggers during the build. 这是为了支持 VS IDE 方案,通过该方案可以为每个项目系统的生成请求注册和注销记录器。This is to support the VS IDE scenario where loggers are registered and unregistered for each project system's build request. 这意味着一个物理生成能拥有多个逻辑生成,每个都带有它自己的记录器集。This means one physical build may have multiple logical builds each with their own set of loggers.

Mux 记录器将作为一般中心 /l 样式记录器向生成管理器注册自身。The Mux logger will register itself with the build manager as a regular central /l style logger. 它将负责根据消息所来自的逻辑生成,从生成管理器中接收消息并将它们发送到正确的记录器上。It will be responsible for receiving messages from the build manager and route them to the correct logger based on the logical build the message came from.

要求:1)将在生成管理器的“开始生成”操作开始时注册多路复用记录器。在生成管理器实际开始生成之前注册的任何记录器将与 MUX 记录器同时获得生成开始事件。在生成管理器开始生成后注册的所有记录器将获得合成的生成开始事件。Requirements: 1) Multiplexing logger will be registered at the beginning of the build manager's Begin build Any loggers registered before the build manager actually started building will get the build started event at the same time as the MUX logger Any loggers registered after the build manager starts the build will get a synthesised build started event. 无法缓存该事件,因为在创建事件时就确定了生成开始事件的时间戳,因此缓存该事件将导致在注册到 MUX 的记录器中提供错误的生成时间。The event cannot be cached because the timestamp of the build started event is determined when the event is created, caching the event would give incorrect build times in the loggers registered to the MUX.

2)生成管理器将对 MUX 记录器进行初始化。2) The MUX logger will be initialized by the build manager. 多路复用器将从生成管理器监听事件源上的所有事件,并将事件正确地路由到已注册的记录器。The mux will listen to all events on the event source from the build manager and will route events correctly to the registered loggers.

3)当“结束生成”中的生成结束时,MUX 记录器将关闭。3) The MUX logger will be shutdown when the build is finished in end build . 此时,它将注销连接到它的所有记录器。At this time it will un-register any loggers attached to it.

4)当每个记录器的第一个项目开始事件的项目完成事件出现时,MUX 记录器将记录“生成完成”事件。4) The MUX logger will log the build finished event when the project finished event for the first project started event is seen for each logger.

正在注册记录器:Registering Loggers: 多路复用记录器将按以下方式工作:系统将使用一个提交 ID 将记录器传递到 MUX 注册记录器方法,该提交 ID 用于将消息路由到正确的记录器。The multiplexing logger will function in the following way: A logger will be passed to the MUX Register logger method with a submission ID which will be used to route a the message to the correct logger. 将创建一个新的事件源,以便可以将传入的记录器注册到该事件源。如果已经记录了生成启动事件,MUX 记录器将创建一个新的 BuildStartedEvent 并将其发送到事件源。A new event source will be created so that the logger passed in can be registered to that event source If the build started event has already been logged the MUX logger will create a new BuildStartedEvent and send that to the event source.

UnregisterLoggers:“生成提交”完成后,将使用提交 ID 调用 UnregisterLoggers 方法。UnregisterLoggers: When a build submission is completed the UnregisterLoggers method will be called with the submission ID. 此时,我们将为提交 ID 查找项目完成事件的成功状态,并将生成完成事件记录到记录器中。At this point we will look up the success state of the project finished event for the submission ID and log a build finished event to the logger. 将清理事件源。The event source will be cleaned up. 这看上去可能很有趣,因为注销操作将来自日志记录操作以外的其他线程。This may be interesting because the unregister will come from a thread other than what is doing the logging. 如果在记录事件时调用注销操作,这可能会导致同步问题。This may create a Synchronization issue, if unregister is called while events are being logged.


处理器体系结构实用工具Processor architecture utilities


用于表示 SDKManifest.xml 中包含的信息的结构Structure to represent the information contained in SDKManifest.xml


具有 SDKManifest.xml 特性的帮助程序类Helper class with attributes of SDKManifest.xml


表示目标平台 sdk 的结构Structure to represent a target platform sdk


此帮助器基类提供用于任务的默认功能。This helper base class provides default functionality for tasks. 此类只能以派生形式实例化。This class can only be instantiated in a derived form.


此类表示项目中传递到任务的单个项。This class represents a single item of the project, as it is passed into a task. TaskItems 不与项目文件中的项元素完全对应,因为这样任务就有权访问未通过项目文件显式传递到任务的数据。TaskItems do not exactly correspond to item elements in project files, because then tasks would have access to data that wasn't explicitly passed into the task via the project file. 这并不是一个安全问题,而是项目文件清晰度和透明度的问题。It's not a security issue, but more just an issue with project file clarity and transparency.

注意:此类必须密封。Note: This class has to be sealed. 它必须密封,因为引擎实例化它自己的此类型副本,因此,如果有人要对其进行扩展,他们不会从引擎获得所需行为。It has to be sealed because the engine instantiates it's own copy of this type and thus if someone were to extend it, they would not get the desired behavior from the engine.


帮助程序记录类 - 包含任务使用的所有记录方法。Helper logging class - contains all the logging methods used by tasks. TaskLoggingHelper 对象由 MSBuild 传递给每个任务。A TaskLoggingHelper object is passed to every task by MSBuild. 对于从 Task 类派生的任务,该任务在 Log 属性中提供。For tasks that derive from the Task class, it is provided in the Log property. 此类是线程安全的:任务可以从任何线程记录。This class is thread safe: tasks can log from any threads.


ToolLocationHelper 提供用于查找 .NET Framework 和 .NET Framework SDK 目录和文件的实用工具方法。ToolLocationHelper provides utility methods for locating .NET Framework and .NET Framework SDK directories and files. 注意:此类的所有公共方法都可用于 MSBuild 项目,以便在函数中使用-在项目评估期间,这些方法必须是安全的。NOTE: All public methods of this class are available to MSBuild projects for use in functions - they must be safe for use during project evaluation.


用于生成可执行文件的任务的基类。Base class used for tasks that spawn an executable. 此类可实现 ToolPath 属性,该属性可用于替代默认路径。This class implements the ToolPath property which can be used to override the default path.


此类包含一些用于帮助跟踪依赖项的实用工具函数This class contains utility functions to assist with tracking dependencies



用于为 ToolLocationHelper 的一些方法指定 .NET Framework 的目标位数Used to specify the targeted bitness of the .NET Framework for some methods of ToolLocationHelper


表示由 Tracker.exe 包装的可执行文件的类型的枚举Enumeration to express the type of executable being wrapped by Tracker.exe


InitializeHostObject 中的返回值。 此枚举定义 ToolTask 在尝试初始化主机对象之后应采取的操作。This enumeration defines what action the ToolTask should take next, after we've tried to initialize the host object.


找到给定产品系列或 SDK 名称的多个版本时应执行的操作What should happen if multiple versions of a given productfamily or sdk name are found


SDK 类型Type of SDK


用于为 ToolLocationHelper 的某些方法指定 .NET Framework 目标版本。Used to specify the targeted version of the .NET Framework for some methods of ToolLocationHelper.


我们可以支持的最新检查的可能类型The possible types of up to date check that we can support


用于指定可视演播室版本的选项。 ToolLocationHelper 某些方法的伴生的工具Used to specify the version of Visual Studio from which to select associated tools for some methods of ToolLocationHelper



依赖项筛选器委托。Dependency filter delegate. 在 TLog 保存的过程中使用,以便让任务有选择地从已编写的关系图中移除依赖项。Used during TLog saves in order for tasks to selectively remove dependencies from the written graph.