ToolTask 类

定义

用于生成可执行文件的任务的基类。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.

public ref class ToolTask abstract : Microsoft::Build::Utilities::Task, Microsoft::Build::Framework::ICancelableTask
public ref class ToolTask abstract : Microsoft::Build::Utilities::Task
public abstract class ToolTask : Microsoft.Build.Utilities.Task, Microsoft.Build.Framework.ICancelableTask
public abstract class ToolTask : Microsoft.Build.Utilities.Task
type ToolTask = class
    inherit Task
    interface ICancelableTask
    interface ITask
type ToolTask = class
    inherit Task
Public MustInherit Class ToolTask
Inherits Task
Implements ICancelableTask
Public MustInherit Class ToolTask
Inherits Task
继承
ToolTask
派生
实现

构造函数

ToolTask()

受保护的构造函数Protected constructor

ToolTask(ResourceManager)

受保护的构造函数Protected constructor

ToolTask(ResourceManager, String)

受保护的构造函数Protected constructor

属性

BuildEngine

生成引擎自动设置此属性,以允许任务回调到其中。The build engine automatically sets this property to allow tasks to call back into it.

(继承自 Task)
BuildEngine2

生成引擎自动设置此属性,以允许任务回调到其中。The build engine automatically sets this property to allow tasks to call back into it. 这是一个便捷属性,因此从此类继承的任务作者不必将值从 IBuildEngine 强制转换为 IBuildEngine2。This is a convenience property so that task authors inheriting from this class do not have to cast the value from IBuildEngine to IBuildEngine2.

(继承自 Task)
BuildEngine3

检索主机提供的生成引擎接口的 IBuildEngine3 版本。Retrieves the IBuildEngine3 version of the build engine interface provided by the host.

(继承自 Task)
BuildEngine4

检索主机提供的生成引擎接口的 IBuildEngine4 版本。Retrieves the IBuildEngine4 version of the build engine interface provided by the host.

(继承自 Task)
BuildEngine5

检索主机提供的生成引擎接口的 IBuildEngine5 版本。Retrieves the IBuildEngine5 version of the build engine interface provided by the host.

(继承自 Task)
BuildEngine6

检索主机提供的生成引擎接口的 IBuildEngine6 版本。Retrieves the IBuildEngine6 version of the build engine interface provided by the host.

(继承自 Task)
BuildEngine7

获取主机提供的生成引擎接口的版本。Gets the version of the build engine interface provided by the host.

(继承自 Task)
EchoOff

当设置为 true 时,它将 / Q 传递到 cmd.exe 命令行,这样命令行不会在 stdout 上得到回显When set to true, it passes /Q to the cmd.exe command line such that the command line does not get echo-ed on stdout

EnvironmentOverride
已过时。

获取路径替代值。Gets the Path override value.

EnvironmentVariables

除了(或者有选择地重写)常规的环境块外,应传递到生成的可执行文件的用等号分隔的环境变量对的数组。Array of equals-separated pairs of environment variables that should be passed to the spawned executable, in addition to (or selectively overriding) the regular environment block.

ExitCode

生成的进程的返回码。The return code of the spawned process. 如果任务记录了任何错误,但进程的退出代码为 0(成功),这设置为 -1。If the task logged any errors, but the process had an exit code of 0 (success), this will be set to -1.

HasLoggedErrors

此 ToolTask 是否记录了任何错误Whether this ToolTask has logged any errors

HelpKeywordPrefix

获取或设置前缀,该前缀用于通过字符串资源名称组成 help 关键字。Gets or sets the prefix used to compose help keywords from string resource names. 如果任务没有与消息关联的 help 关键字,则可以忽略此属性或将其设置为 null。If a task does not have help keywords associated with its messages, it can ignore this property or set it to null. 如果前缀设置为空字符串,则字符串资源名称将逐字用作 help 关键字。If the prefix is set to an empty string, then string resource names will be used verbatim as help keywords. 有关如何使用此前缀的示例,请参阅 TaskLoggingHelper.LogErrorWithCodeFromResources(string, object[]) 方法。For an example of how this prefix is used, see the TaskLoggingHelper.LogErrorWithCodeFromResources(string, object[]) method.

(继承自 Task)
HostObject

如果主机 IDE 具有与此特定任务关联的主机对象,则生成引擎会设置此属性。The build engine sets this property if the host IDE has associated a host object with this particular task.

(继承自 Task)
Log

获取包含任务记录方法的 TaskLoggingHelper 类的实例。Gets an instance of a TaskLoggingHelper class containing task logging methods. taskLoggingHelper 是一个 MarshallByRef 对象,如果父任务正在创建 appdomain 并将该对象封送到其中,则该对象需要调用 MarkAsInactive。The taskLoggingHelper is a MarshallByRef object which needs to have MarkAsInactive called if the parent task is making the appdomain and marshaling this object into it. 如果在任务执行结束时未卸载 appdomain,并且未调用 MarkAsInactive 方法,则将导致在其中创建任务的 appdomain 中的任务实例泄漏。If the appdomain is not unloaded at the end of the task execution and the MarkAsInactive method is not called this will result in a leak of the task instances in the appdomain the task was created within.

(继承自 Task)
LogStandardErrorAsError

应将标准错误流上接收的所有消息作为错误记录。Should ALL messages received on the standard error stream be logged as errors.

ResponseFileEncoding

用于指定响应文件编码的可替代属性,默认为 UTF8Overridable property specifying the encoding of the response file, UTF8 by default

StandardErrorEncoding

可重写的属性,用于指定捕获的任务标准错误流的编码值Overridable property specifying the encoding of the captured task standard error stream

StandardErrorImportance

任务参数:用于从标准错误流记录文本的重要性。Task Parameter: Importance with which to log text from the standard error stream.

StandardErrorImportanceToUse

记录标准错误消息时使用的实际重要性。The actual importance at which standard error messages will be logged.

StandardErrorLoggingImportance

用于从标准错误流记录文本的重要性。Importance with which to log text from the standard error stream.

StandardOutputEncoding

可重写的属性,用于指定捕获的任务标准输出流的编码值Overridable property specifying the encoding of the captured task standard output stream

StandardOutputImportance

任务参数:关于记录标准输出流的文本的重要性。Task Parameter: Importance with which to log text from the standard out stream.

StandardOutputImportanceToUse

记录标准输出消息时使用的实际重要性。The actual importance at which standard out messages will be logged.

StandardOutputLoggingImportance

从标准输出流中记录文本时使用的重要性。Importance with which to log text from in the standard out stream.

TaskProcessTerminationTimeout

在取消任务之前等待该任务终止所需的超时。A timeout to wait for a task to terminate before killing it. 以毫秒为单位。In milliseconds.

TaskResources

获取或设置任务的区域性特定资源。Gets or sets the task's culture-specific resources. 派生类应在构造期间注册资源,如果它们有本地化字符串,则可以通过此属性注册。Derived classes should register their resources either during construction, or via this property, if they have localized strings.

(继承自 Task)
Timeout

项目可见属性,使用户可以指定终止任务可执行文件前留出的时间。Project visible property that allows the user to specify an amount of time after which the task executable is terminated.

ToolCanceled

用于在已取消某个工具时发出信号。Used to signal when a tool has been cancelled.

ToolExe

项目可以设置此值以重写任务的 ToolName。Projects may set this to override a task's ToolName. 任务可能会重写此内容以避免这种情况。Tasks may override this to prevent that.

ToolName

由派生类实现。Implemented by the derived class. 返回一个字符串,该字符串是要运行“resgen.exe”等程序的基础 .EXE 的名称。仅由 ToolExe getter 使用。Returns a string which is the name of the underlying .EXE to run e.g. "resgen.exe" Only used by the ToolExe getter.

ToolPath

项目可见属性允许用户替代可执行文件的路径。Project-visible property allows the user to override the path to the executable.

UseCommandProcessor

当设置为 true 时,工具任务将为命令行创建一个批处理文件并使用命令处理器执行该文件,而不是直接执行该命令。When set to true, the tool task will create a batch file for the command-line and execute that using the command-processor, rather than executing the command directly.

YieldDuringToolExecution

当设置为 true 时,此任务会在其任务执行时生成节点。When set to true, this task will yield the node when its task is executing.

方法

AdjustCommandsForOperatingSystem(String)

将反斜杠替换为特定于操作系统的路径分隔符,除非反斜杠是有意添加的。Replace backslashes with OS-specific path separators, except when likely that the backslash is intentional.

CallHostObjectToExecute()

如果任务支持宿主对象,应能替代此方法。We expect the tasks to override this method, if they support host objects. 该实现应会调用宿主对象以执行任务的实际工作。The implementation should call into the host object to perform the real work of the task. 例如,对于 Csc 和 Vbc 等编译器任务,此方法将在宿主对象上调用 Compile()。For example, for compiler tasks like Csc and Vbc, this method would call Compile() on the host object.

Cancel()

通过以下方式取消正在执行任务的进程:请求该进程正常关闭,在经过短时间的等待之后,强制终止该进程。Cancels the process executing the task by asking it to close nicely, then after a short period, forcing termination.

DeleteTempFile(String)

删除临时文件。Delete temporary file. 如果删除由于某种原因而失败(例如,文件被防病毒软件锁定),则调用不会引发异常。If the delete fails for some reason (e.g. file locked by anti-virus) then the call will not throw an exception. 这时会记录一个警告,但生成不会失败。Instead a warning will be logged, but the build will not fail.

Equals(Object)

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

(继承自 Object)
Execute()

此方法使用给定参数调用该工具。This method invokes the tool with the given parameters.

ExecuteTool(String, String, String)

写出一个临时响应文件,然后通过 shell 执行请求的工具。Writes out a temporary response file and shell-executes the tool requested. 启用工具输出的并发记录。Enables concurrent logging of the output of the tool.

GenerateCommandLineCommands()

返回一个字符串,其中包含不能进入响应文件且必须直接转到命令行的开关和其他信息。Returns a string with those switches and other information that can't go into a response file and must go directly onto the command line. 在 ValidateParameters 和 SkipTaskExecution 之后调用Called after ValidateParameters and SkipTaskExecution

GenerateFullPathToTool()

获取完全限定的工具名称。Gets the fully qualified tool name. 如果 ToolTask 应在系统路径中搜索工具,则返回 ToolExe。Should return ToolExe if ToolTask should search for the tool in the system path. 如果设置了 ToolPath,则忽略。If ToolPath is set, this is ignored.

GenerateResponseFileCommands()

返回含有那些开关和其他可放入响应文件中的信息的字符串。Returns a string with those switches and other information that can go into a response file. 在 ValidateParameters 和 SkipTaskExecution 之后调用Called after ValidateParameters and SkipTaskExecution

GetHashCode()

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

(继承自 Object)
GetProcessStartInfo(String, String, String)

初始化生成执行该工具的进程所需的信息。Initializes the information required to spawn the process executing the tool.

GetResponseFileSwitch(String)

返回工具可执行文件用来指定响应文件的命令行开关。Returns the command line switch used by the tool executable to specify the response file. 将仅在任务从 GetResponseFileCommands 返回非空字符串时调用。在 ValidateParameters、SkipTaskExecution 和 GetResponseFileCommands 之后调用Will only be called if the task returned a non empty string from GetResponseFileCommands Called after ValidateParameters, SkipTaskExecution and GetResponseFileCommands

GetType()

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

(继承自 Object)
GetWorkingDirectory()

获取要用于进程的工作目录。Gets the working directory to use for the process. 如果 ToolTask 应使用当前目录,则返回 null。Should return null if ToolTask should use the current directory.

HandleTaskExecutionErrors()

允许工具处理返回代码。Allows tool to handle the return code. 此方法将仅在 exitCode 为非零的情况下调用。This method will only be called with non-zero exitCode.

InitializeHostObject()

如果任务支持宿主对象,应能替代此方法。We expect tasks to override this method if they support host objects. 该实现应确保宿主对象已能够执行任务的实际工作。The implementation should make sure that the host object is ready to perform the real work of the task.

LogEventsFromTextOutput(String, MessageImportance)

在 TaskLoggingHelper 上调用方法以解析一行文本,以查看是否存在有关规范格式的错误或警告。Calls a method on the TaskLoggingHelper to parse a single line of text to see if there are any errors or warnings in canonical format. 如有必要,可以由派生类替代。This can be overridden by the derived class if necessary.

LogPathToTool(String, String)

记录工具名称和运行路径。Logs the tool name and the path from where it is being run.

LogToolCommand(String)

记录要执行的实际命令行(或任务希望日志显示的内容)Logs the actual command line about to be executed (or what the task wants the log to show)

MemberwiseClone()

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

(继承自 Object)
ProcessStarted()

ExecuteTool(String, String, String) 中的 Start() 之后调用的可替代函数Overridable function called after Start() in ExecuteTool(String, String, String)

ResponseFileEscape(String)

用来转义响应文件的可替代方法Overridable method to escape content of the response file

SkipTaskExecution()

如果并非一定要执行任务,则返回 true。Returns true if task execution is not necessary. 在 ValidateParameters 后执行Executed after ValidateParameters

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
ValidateParameters()

在派生类中实现Implemented in the derived class

适用于