dotnet msbuilddotnet msbuild

本主题适用于:✓ .NET Core 1.x SDK .NET Core 2.x SDKThis topic applies to: ✓ .NET Core 1.x SDK .NET Core 2.x SDK

nameName

dotnet msbuild - 生成项目及其所有依赖项。dotnet msbuild - Builds a project and all of its dependencies.

摘要Synopsis

dotnet msbuild <msbuild_arguments> [-h]

说明Description

dotnet msbuild 命令允许访问功能完备的 MSBuild。The dotnet msbuild command allows access to a fully functional MSBuild.

该命令与仅适用于 SDK 样式项目的现有 MSBuild 命令行客户端具有完全相同的功能。The command has the exact same capabilities as the existing MSBuild command-line client for SDK-style project only. 选项一致。The options are all the same. 有关可用选项的详细信息,请参阅 MSBuild 命令行参考For more information about the available options, see the MSBuild Command-Line Reference.

dotnet build 命令相当于 dotnet msbuild -restore -target:BuildThe dotnet build command is equivalent to dotnet msbuild -restore -target:Build. dotnet build 更常用于生成项目,但 dotnet msbuild 可使用户更好地进行控制。dotnet build is more commonly used for building projects, but dotnet msbuild gives you more control. 例如,如果想要运行特定目标(而不运行生成目标),可能更倾向于使用 dotnet msbuildFor example, if you have a specific target you want to run (without running the build target), you probably want to use dotnet msbuild.

示例Examples

  • 生成项目及其依赖项:Build a project and its dependencies:

    dotnet msbuild
    
  • 使用“发布”配置生成项目及其依赖项:Build a project and its dependencies using Release configuration:

    dotnet msbuild -p:Configuration=Release
    
  • 运行发布目标并发布 osx.10.11-x64 RID:Run the publish target and publish for the osx.10.11-x64 RID:

    dotnet msbuild -t:Publish -p:RuntimeIdentifiers=osx.10.11-x64
    
  • 请参阅包含 SDK 添加的所有目标的整个项目:See the whole project with all targets included by the SDK:

    dotnet msbuild -pp