MSBuild 命令行参考MSBuild command-line reference

使用 MSBuild.exe 生成项目或解决方案文件时,可以包含几个开关来指定过程的各个方面。When you use MSBuild.exe to build a project or solution file, you can include several switches to specify various aspects of the process.

每个开关都有两种形式:-switch 和 /switch。Every switch is available in two forms: -switch and /switch. 本文档仅介绍 -switch 形式。The documentation only shows the -switch form. 开关不区分大小写。Switches are not case-sensitive. 如果从 Windows 命令提示符之外的 shell 运行 MSBuild,则开关的参数列表(用分号或逗号分隔)可能需要单引号或双引号,以确保将列表传递到 MSBuild,而不是由 shell 解释。If you run MSBuild from a shell other than the Windows command prompt, lists of arguments to a switch (separated by semicolons or commas) might need single or double quotes to ensure that lists are passed to MSBuild instead of interpreted by the shell.

语法Syntax

MSBuild.exe [Switches] [ProjectFile]

自变量Arguments

参数Argument 描述Description
ProjectFile 在指定项目文件中生成目标。Builds the targets in the project file that you specify. 如果不指定项目文件,则 MSBuild 会在当前工作目录中搜索以“proj”结尾的文件扩展名并使用该文件。If you don't specify a project file, MSBuild searches the current working directory for a file name extension that ends in proj and uses that file. 还可以为此参数指定 Visual Studio 解决方案文件。You can also specify a Visual Studio solution file for this argument.

开关Switches

开关Switch 缩写形式Short form 描述Description
-detailedSummary-detailedSummary -ds-ds 在生成日志末尾显示有关生成的配置以及如何将它们安排到节点中的详细信息。Show detailed information at the end of the build log about the configurations that were built and how they were scheduled to nodes.
-graphBuild[:True or False]-graphBuild[:True or False] -graph[:True or False]-graph[:True or False] 使 MSBuild 构造和生成项目图。Causes MSBuild to construct and build a project graph. 构图涉及标识对窗体依赖项的项目引用。Constructing a graph involves identifying project references to form dependencies. 生成该图涉及到尝试在引用它们的项目之前生成项目引用,这不同于传统的 MSBuild 计划。Building that graph involves attempting to build project references prior to the projects that reference them, differing from traditional MSBuild scheduling. 需要 MSBuild 16 或更高版本。Requires MSBuild 16 or later.
-help-help /?/? 或 -hor -h 显示用法信息。Display usage information. 以下命令是一个示例:The following command is an example:

msbuild.exe -?
-ignoreProjectExtensions: extensions-ignoreProjectExtensions: extensions -ignore: extensions-ignore: extensions 确定要生成的项目文件时忽略指定扩展名。Ignore the specified extensions when determining which project file to build. 使用分号或逗号分隔多个扩展名,如以下示例所示:Use a semicolon or a comma to separate multiple extensions, as the following example shows:

-ignoreprojectextensions:.vcproj,.sln
-interactive[:True or False]-interactive[:True or False] - 指示允许生成中的操作与用户交互。Indicates that actions in the build are allowed to interact with the user. 不要在不期望交互的自动方案中使用此参数。Do not use this argument in an automated scenario where interactivity is not expected. 指定 -interactive 等效于指定 -interactive:true。Specifying -interactive is the same as specifying -interactive:true. 使用此参数重写来自响应文件的值。Use the parameter to override a value that comes from a response file.
-isolateProjects[:True or False]-isolateProjects[:True or False] -isolate[:True or False]-isolate[:True or False] 使 MSBuild 单独生成每个项目。Causes MSBuild to build each project in isolation. 这是 MSBuild 更严格的模式,因为它要求在计算时可以静态发现项目图,但生成大量项目时可以改进计划并减少内存开销。This is a more restrictive mode of MSBuild as it requires that the project graph be statically discoverable at evaluation time, but can improve scheduling and reduce memory overhead when building a large set of projects.
-maxCpuCount[:number]-maxCpuCount[:number] -m[:number]-m[:number] 指定生成时要使用的最大并发进程数。Specifies the maximum number of concurrent processes to use when building. 如果不包含此开关,则默认值为 1。If you don't include this switch, the default value is 1. 如果包含此开关而没有指定值,MSBuild 将使用计算机中的处理器总数作为其值。If you include this switch without specifying a value, MSBuild will use up to the number of processors in the computer. 有关详细信息,请参阅并行生成多个项目For more information, see Building multiple projects in parallel.

下面的示例指示 MSBuild 使用三个 MSBuild 进程进行生成,这允许同时生成三个项目:The following example instructs MSBuild to build using three MSBuild processes, which allows three projects to build at the same time:

msbuild myproject.proj -maxcpucount:3
-noAutoResponse-noAutoResponse -noautorsp-noautorsp 不自动包含任何 MSBuild.rsp 文件。Don't include any MSBuild.rsp files automatically.
-nodeReuse:value-nodeReuse:value -nr:value-nr:value 启用或禁用 MSBuild 节点的重复使用。Enable or disable the re-use of MSBuild nodes. 你可以指定以下值:You can specify the following values:

- True- True. 节点在生成完成之后保留,以便后续生成可以使用它们(默认值)。Nodes remain after the build finishes so that subsequent builds can use them (default).
- False- False. 节点在生成完成之后不保留。Nodes don't remain after the build completes.

节点对应于正在执行的项目。A node corresponds to a project that's executing. 如果你添加 -maxcpucount 开关,多个节点可并发执行。If you include the -maxcpucount switch, multiple nodes can execute concurrently.
-nologo-nologo 不显示启动版权标志或版权消息。Don't display the startup banner or the copyright message.
-preprocess[:filepath]-preprocess[:filepath] -pp[:filepath]-pp[:filepath] 通过内联会在生成期间导入的所有文件(标记其边界)创建单一的聚合项目文件。Create a single, aggregated project file by inlining all the files that would be imported during a build, with their boundaries marked. 可以使用此开关更轻松地确定所导入的文件、从中导入文件的位置以及参与生成的文件。You can use this switch to more easily determine which files are being imported, from where the files are being imported, and which files contribute to the build. 使用此开关时,不生成项目。When you use this switch, the project isn't built.

如果指定 filepath,则会将聚合项目文件输出到文件。If you specify a filepath, the aggregated project file is output to the file. 否则,输出将显示在控制台窗口中。Otherwise, the output appears in the console window.

有关如何使用 Import 元素将项目文件插入到其他项目文件的详细信息,请参阅 Import 元素 (MSBuild)如何:在多个项目文件中使用同一目标For information about how to use the Import element to insert a project file into another project file, see Import element (MSBuild) and How to: Use the same target in multiple project files.
-outputResultsCache[:cacheFile]-outputResultsCache[:cacheFile] -orc[:cacheFile]-orc[:cacheFile] MSBuild 将在生成结束时将生成结果缓存的内容写入 Output 缓存文件。Output cache file where MSBuild will write the contents of its build result caches at the end of the build. 设置此项还会打开独立生成 (-isolate)。Setting this also turns on isolated builds (-isolate).
-profileEvaluation:<file>-profileEvaluation:<file> - 分析 MSBuild 计算,并将结果写入指定的文件。Profiles MSBuild evaluation and writes the result to the specified file. 如果指定的文件的扩展名为“.md”,则以 Markdown 格式生成结果。If the extension of the specified file is '.md', the result is generated in Markdown format. 否则,将生成制表符分隔文件。Otherwise, a tab-separated file is produced.
-property:name=value-property:name=value -p:name=value-p:name=value 设置或重写指定项目级属性,其中 name 是属性名称,value 是属性值。Set or override the specified project-level properties, where name is the property name and value is the property value. 单独指定每个属性,或使用分号或逗号分隔多个属性,如以下示例所示:Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows:

-property:WarningLevel=2;OutDir=bin\Debug
-restore-restore -r-r 在生成实际目标之前运行 Restore 目标。Runs the Restore target prior to building the actual targets.
-restoreProperty:name=value-restoreProperty:name=value -rp:name=value-rp:name=value 仅在还原期间设置或重写这些项目级别的属性,不要使用通过 -property 参数指定的属性。Set or override these project-level properties only during restore and do not use properties specified with the -property argument. name 是属性名称,value 是属性值。name is the property name, and value is the property value. 使用分号或逗号分隔多个属性,或单独指定每个属性。Use a semicolon or a comma to separate multiple properties, or specify each property separately.
-target:targets-target:targets -t:targets-t:targets 在项目中生成指定目标。Build the specified targets in the project. 单独指定每个目标,或使用分号或逗号分隔多个目标,如以下示例所示:Specify each target separately, or use a semicolon or comma to separate multiple targets, as the following example shows:

-target:PrepareResources;Compile

如果使用此开关指定任何目标,则它们会代替项目文件中的 DefaultTargets 特性中的任何目标来运行。If you specify any targets by using this switch, they are run instead of any targets in the DefaultTargets attribute in the project file. 有关详细信息,请参阅目标生成顺序如何:指定首先生成的目标For more information, see Target build order and How to: Specify which target to build first.

目标是一组任务。A target is a group of tasks. 有关详细信息,请参阅目标For more information, see Targets.
-targets[:file]-targets[:file] -ts[:file]-ts[:file] 将可用目标的列表写入指定的文件(如果未指定任何文件,则写入输出设备),而无需实际执行生成过程。Write the list of available targets to the specified file (or the output device, if no file is specified), without actually executing the build process.
-toolsVersion:version-toolsVersion:version -tv:version-tv:version 指定要用于生成项目的工具集的版本,如以下示例所示:-toolsversion:3.5Specifies the version of the Toolset to use to build the project, as the following example shows: -toolsversion:3.5

使用此开关可以生成项目并指定与 Project 元素 (MSBuild) 中指定的版本不同的版本。By using this switch, you can build a project and specify a version that differs from the version that's specified in the Project element (MSBuild). 有关详细信息,请参阅重写 ToolsVersion 设置For more information, see Overriding ToolsVersion settings.

对于 MSBuild 4.5,可以为 version 指定以下值:2.0、3.5 和 4.0。For MSBuild 4.5, you can specify the following values for version: 2.0, 3.5, and 4.0. 如果指定 4.0,VisualStudioVersion 生成属性会指定要使用的子工具集。If you specify 4.0, the VisualStudioVersion build property specifies which sub-toolset to use. 有关详细信息,请参阅工具集 (ToolsVersion) 的“子工具集”一节。For more information, see the Sub-toolsets section of Toolset (ToolsVersion).

包含用于生成应用程序的任务、目标和工具的工具集。A Toolset consists of tasks, targets, and tools that are used to build an application. 工具包括编译器,例如 csc.exe 和 vbc.exe 。The tools include compilers such as csc.exe and vbc.exe. 有关工具集的详细信息,请参阅工具集 (ToolsVersion)标准和自定义工具集配置多定向For more information about Toolsets, see Toolset (ToolsVersion), Standard and custom toolset configurations, and Multitargeting. 注意: 工具集版本与目标框架不同,后者是生成项目以在其上运行的 .NET Framework 的版本。Note: The toolset version isn't the same as the target framework, which is the version of the .NET Framework on which a project is built to run. 有关详细信息,请参阅目标框架和目标平台For more information, see Target framework and target platform.
-validate:[schema]-validate:[schema] -val[schema]-val[schema] 验证项目文件,如果验证成功,则生成项目。Validate the project file and, if validation succeeds, build the project.

如果没有指定 schema,则针对默认架构验证项目。If you don't specify schema, the project is validated against the default schema.

如果指定 schema,则针对指定的架构验证项目。If you specify schema, the project is validated against the schema that you specify.

下面的设置是一个示例:-validate:MyExtendedBuildSchema.xsdThe following setting is an example: -validate:MyExtendedBuildSchema.xsd
-verbosity:level-verbosity:level -v:level-v:level 指定要在生成日志中显示的信息量。Specifies the amount of information to display in the build log. 每个记录器基于为该记录器设置的详细级别显示事件。Each logger displays events based on the verbosity level that you set for that logger.

可以指定以下详细级别:q[uiet]m[inimal]n[ormal](默认)、d[etailed]diag[nostic]You can specify the following verbosity levels: q[uiet], m[inimal], n[ormal] (default), d[etailed], and diag[nostic].

下面的设置是一个示例:-verbosity:quietThe following setting is an example: -verbosity:quiet
-version-version -ver-ver 仅显示版本信息。Display version information only. 不生成项目。The project isn't built.
@file 从文本文件插入命令行开关。Insert command-line switches from a text file. 如果具有多个文件,可单独指定它们。If you have multiple files, you specify them separately. 有关详细信息,请参阅响应文件For more information, see Response files.
-warnAsError[:code[;code2]-warnAsError[:code[;code2] -err[:code[;code2]-err[:code[;code2] 要视为错误的警告代码的列表。List of warning codes to treats as errors. 使用分号或逗号分隔多个警告代码。Use a semicolon or a comma to separate multiple warning codes. 若要将所有警告视为错误,请使用不带任何值的开关。To treat all warnings as errors, use the switch with no values. 如果警告被视为错误,则目标将像对待警告一样继续执行,但总体生成会失败。When a warning is treated as an error the target continues to execute as if it was a warning but the overall build fails.

示例:-err:MSB4130Example: -err:MSB4130
-warnAsMessage[:code[;code2]-warnAsMessage[:code[;code2] -noWarn[:code[;code2]-noWarn[:code[;code2] 要视为低重要性消息的警告代码的列表。List of warning codes to treats as low importance messages. 使用分号或逗号分隔多个警告代码。Use a semicolon or a comma to separate multiple warning codes.

示例:-noWarn:MSB3026Example: -noWarn:MSB3026

记录器的开关Switches for loggers

开关Switch 缩写形式Short form 描述Description
-binaryLogger[:[LogFile=]output.binlog-binaryLogger[:[LogFile=]output.binlog
[;ProjectImports=[None,Embed,ZipFile]]][;ProjectImports=[None,Embed,ZipFile]]]
-bl-bl 将所有生成事件串行化为压缩的二进制文件。Serializes all build events to a compressed binary file. 默认情况下,该文件位于当前目录中,名称为 msbuild.binlog。By default the file is in the current directory and named msbuild.binlog. 二进制日志是对生成过程的详细描述,可在将来用于重建文本日志,或由其它分析工具使用。The binary log is a detailed description of the build process that can later be used to reconstruct text logs and used by other analysis tools. 二进制日志的大小通常只有最详细文本诊断级日志的 1/10 到 1/20,但却能包含更多信息。A binary log is usually 10-20x smaller than the most detailed text diagnostic-level log, but it contains more information.

二进制记录器默认收集项目文件的源文本,包括所有导入的项目,以及在生成期间所遇到的目标文件。The binary logger by default collects the source text of project files, including all imported projects and target files encountered during the build. 可选的 ProjectImports 开关控制此行为:The optional ProjectImports switch controls this behavior:

- ProjectImports=None。- ProjectImports=None. 不收集项目导入。Don't collect the project imports.
- ProjectImports=Embed。- ProjectImports=Embed. 在日志文件中嵌入项目导入(默认)。Embed project imports in the log file (default).
- ProjectImports=ZipFile。- ProjectImports=ZipFile. 将项目文件保存至 <output>.projectimports.zip,其中 <output> 的名称与二进制日志文件的名称相同。Save project files to <output>.projectimports.zip where <output> is the same name as the binary log file name.

ProjectImports 的默认设置为“嵌入”。The default setting for ProjectImports is Embed.
请注意:记录器不收集 .cs、.cpp 等非 MSBuild 源文件 。Note: the logger does not collect non-MSBuild source files such as .cs, .cpp etc.
将 .binlog 文件作为参数而非项目/解决方案传递给 msbuild.exe 可“播放”该文件 。A .binlog file can be "played back" by passing it to msbuild.exe as an argument instead of a project/solution. 其他记录器将接收日志文件中包含的信息,就像原始生成发生时那样。Other loggers will receive the information contained in the log file as if the original build was happening. 若要详细了解二进制日志及其使用情况,可访问 https://github.com/Microsoft/msbuild/wiki/Binary-LogYou can read more about the binary log and its usages at: https://github.com/Microsoft/msbuild/wiki/Binary-Log

示例:Examples:
- -bl
- -bl:output.binlog
- -bl:output.binlog;ProjectImports=None
- -bl:output.binlog;ProjectImports=ZipFile
- -bl:..\..\custom.binlog
- -binaryLogger
-consoleLoggerParameters:-consoleLoggerParameters:

parameters
-clp:parameters-clp:parameters 将指定的参数传递到控制台记录器,后者会在控制台窗口中显示生成信息。Pass the parameters that you specify to the console logger, which displays build information in the console window. 可以指定以下参数:You can specify the following parameters:

- PerformanceSummary- PerformanceSummary. 显示在任务、目标和项目中所花费的时间。Show the time that's spent in tasks, targets, and projects.
- Summary- Summary. 在末尾显示错误和警告摘要。Show the error and warning summary at the end.
- NoSummary- NoSummary. 不在末尾显示错误和警告摘要。Don't show the error and warning summary at the end.
- ErrorsOnly- ErrorsOnly. 仅显示错误。Show only errors.
- WarningsOnly- WarningsOnly. 仅显示警告。Show only warnings.
- NoItemAndPropertyList- NoItemAndPropertyList. 如果详细级别设置为 diagnostic,则不在每个项目生成开头显示项和属性的列表。Don't show the list of items and properties that would appear at the start of each project build if the verbosity level is set to diagnostic.
- ShowCommandLine- ShowCommandLine. 显示 TaskCommandLineEvent 消息。Show TaskCommandLineEvent messages.
- ShowTimestamp- ShowTimestamp. 将时间戳显示为任何消息的前缀。Show the timestamp as a prefix to any message.
- ShowEventId- ShowEventId. 显示每个已启动事件、已完成事件和消息的事件 ID。Show the event ID for each started event, finished event, and message.
- ForceNoAlign- ForceNoAlign. 不将文本与控制台缓冲区大小对齐。Don't align the text to the size of the console buffer.
- DisableConsoleColor- DisableConsoleColor. 将默认控制台颜色用于所有日志记录消息。Use the default console colors for all logging messages.
- DisableMPLogging- DisableMPLogging. 在非多处理器模式下运行时,禁用输出的多处理器日志记录样式。Disable the multiprocessor logging style of output when running in non-multiprocessor mode.
- EnableMPLogging- EnableMPLogging. 启用多处理器日志记录样式(即使在非多处理器模式下运行)。Enable the multiprocessor logging style even when running in non-multiprocessor mode. 默认情况下,此日志记录样式处于启用状态。This logging style is on by default.
- Verbosity- Verbosity. 重写此记录器的 -verbosity 设置。Override the -verbosity setting for this logger.

使用分号分隔多个参数,如以下示例所示:Use a semicolon to separate multiple parameters, as the following example shows:

-consoleloggerparameters:PerformanceSummary;NoSummary -verbosity:minimal

默认控制台记录器的详细级别为 normal,并包括 SummaryThe default console logger is at normal verbosity and includes a Summary.
-distributedFileLogger-distributedFileLogger -dfl-dfl 将每个 MSBuild 节点的生成输出记录到其自己的文件。Log the build output of each MSBuild node to its own file. 这些文件的初始位置是当前目录。The initial location for these files is the current directory. 默认情况下,这些文件命名为 MSBuild<NodeId>.log。By default, the files are named MSBuild<NodeId>.log. 可使用 -fileLoggerParameters 开关指定文件位置和 fileLogger 的其他参数。You can use the -fileLoggerParameters switch to specify the location of the files and other parameters for the fileLogger.

如果你使用 -fileLoggerParameters 开关命名日志文件,分布式记录器会在为每个节点创建日志文件时,将相应名称用作模板,并将节点 ID 追加到相应名称中。If you name a log file by using the -fileLoggerParameters switch, the distributed logger will use that name as a template and append the node ID to that name when creating a log file for each node.
-distributedLogger:-distributedLogger:

central logger*

forwarding logger
-dl:central logger*forwarding logger-dl:central logger*forwarding logger 记录 MSBuild 中的事件,将不同记录器实例附加到每个节点。Log events from MSBuild, attaching a different logger instance to each node. 若要指定多个记录器,请分别指定每个记录器。To specify multiple loggers, specify each logger separately.

使用记录器语法指定记录器。You use the logger syntax to specify a logger. 有关记录器语法,请参阅下面的 logger 开关。For the logger syntax, see the -logger switch below.

下面的示例演示如何使用此开关:The following examples show how to use this switch:

-dl:XMLLogger,MyLogger,Version=1.0.2,Culture=neutral

-dl:MyLogger,C:\My.dll*ForwardingLogger,C:\Logger.dll
-fileLogger-fileLogger

[number][number]
-fl[number]-fl[number] 将生成输出记录到当前目录中的单个文件。Log the build output to a single file in the current directory. 如果没有指定 number,输出文件名为 msbuild.log。If you don't specify number, the output file is named msbuild.log. 如果指定 number,则输出文件名为 msbuild<n>.log,其中 <n> 是 numberIf you specify number, the output file is named msbuild<n>.log, where <n> is number. Number 可以是 1 到 9 的数字。Number can be a digit from 1 to 9.

可使用 -fileLoggerParameters 开关指定文件位置和 fileLogger 的其他参数。You can use the -fileLoggerParameters switch to specify the location of the file and other parameters for the fileLogger.
-fileLoggerParameters[number]:-fileLoggerParameters[number]:

parameters
-flp[ number]: parameters-flp[ number]: parameters 为文件记录器和分布式文件记录器指定任何额外参数。Specifies any extra parameters for the file logger and the distributed file logger. 若有此开关,表明存在对应的 -filelogger[number] 开关。The presence of this switch implies that the corresponding -filelogger[number] switch is present. Number 可以是 1 到 9 的数字。Number can be a digit from 1 to 9.

可使用针对 -consoleloggerparameters 列出的所有参数。You can use all parameters that are listed for -consoleloggerparameters. 还可以使用以下一个或多个参数:You can also use one or more of the following parameters:

- LogFile- LogFile. 写入生成日志的日志文件的路径。The path to the log file into which the build log is written. 分布式文件记录器将此路径用作其日志文件的名称的前缀。The distributed file logger prefixes this path to the names of its log files.
- Append- Append. 确定是将生成日志追加到日志文件还是覆盖它。Determines whether the build log is appended to the log file or overwrites it. 设置该开关时,生成日志将追加到日志文件。When you set the switch, the build log is appended to the log file. 此开关不存在时,将覆盖现有日志文件的内容。When the switch is not present, the contents of an existing log file are overwritten.
示例:msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log;appendExample: msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log;append
如果包含显式 truefalse 设置,则无论设置如何,都将追加日志。If you include an explicit true or false setting, the log is appended regardless of the setting. 如果不包含追加开关,则会覆盖日志。If you do not include the append switch, the log is overwritten.
在此例中会覆盖文件:msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.logIn this case the file is overwritten: msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log
在此例中会追加文件:msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log;append=trueIn this case the file is appended: msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log;append=true
在此例中会追加文件:msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log;append=falseIn this case the file is appended: msbuild myfile.proj -flp:FileLogger,Microsoft.Build;logfile=MyLog.log;append=false
- Encoding- Encoding. 指定文件的编码(例如,UTF-8、Unicode 或 ASCII)。Specifies the encoding for the file (for example, UTF-8, Unicode, or ASCII).

下面的示例为警告和错误生成单独的日志文件:The following example generates separate log files for warnings and errors:

-flp1:logfile=errors.txt;errorsonly -flp2:logfile=warnings.txt;warningsonly

下面的示例演示其他可能性:The following examples show other possibilities:

-fileLoggerParameters:LogFile=MyLog.log;Append; Verbosity=diagnostic;Encoding=UTF-8

-flp:Summary;Verbosity=minimal;LogFile=msbuild.sum

-flp1:warningsonly;logfile=msbuild.wrn

-flp2:errorsonly;logfile=msbuild.err
-logger:-logger:

logger
-l:logger-l:logger 指定要用于记录 MSBuild 中的事件的记录器。Specifies the logger to use to log events from MSBuild. 若要指定多个记录器,请分别指定每个记录器。To specify multiple loggers, specify each logger separately.

将以下语法用于 logger: [``LoggerClass``,]``LoggerAssembly``[;``LoggerParameters``]Use the following syntax for logger: [``LoggerClass``,]``LoggerAssembly``[;``LoggerParameters``]

将以下语法用于 LoggerClass: [``PartialOrFullNamespace``.]``LoggerClassNameUse the following syntax for LoggerClass: [``PartialOrFullNamespace``.]``LoggerClassName

如果程序集恰好包含一个记录器,则不必指定记录器类。You don't have to specify the logger class if the assembly contains exactly one logger.

将以下语法用于 LoggerAssembly{``AssemblyName``[,``StrongName``] &#124; AssemblyFile``}Use the following syntax for LoggerAssembly: {``AssemblyName``[,``StrongName``] &#124; AssemblyFile``}

记录器参数是可选的,传递给记录器时与输入时完全一致。Logger parameters are optional and are passed to the logger exactly as you enter them.

下面的示例使用 -logger 开关。The following examples use the -logger switch.

-logger:XMLLogger,MyLogger,Version=1.0.2,Culture=neutral

-logger:XMLLogger,C:\Loggers\MyLogger.dll;OutputAsHTML
-noConsoleLogger-noConsoleLogger -noconlog-noconlog 禁用默认控制台记录器,不将事件记录到控制台。Disable the default console logger, and don't log events to the console.

示例Example

下面的示例生成 MyProject.proj 项目的 rebuild 目标。The following example builds the rebuild target of the MyProject.proj project.

MSBuild.exe MyProject.proj -t:rebuild

示例Example

可以使用 MSBuild.exe 执行更复杂的生成。You can use MSBuild.exe to perform more complex builds. 例如,可以使用它在解决方案中生成特定项目的特定目标。For example, you can use it to build specific targets of specific projects in a solution. 下面的示例重新生成项目 NotInSolutionFolder 并清理项目 InSolutionFolder(位于 NewFolder 解决方案文件夹中)。The following example rebuilds the project NotInSolutionFolder and cleans the project InSolutionFolder, which is in the NewFolder solution folder.

msbuild SlnFolders.sln -t:NotInSolutionfolder:Rebuild;NewFolder\InSolutionFolder:Clean

请参阅See also