dotnet msbuilddotnet msbuild

本文适用于: ✔️ .NET Core 2.x SDK 及更高版本This article applies to: ✔️ .NET Core 2.x SDK and later versions


dotnet msbuild - 生成项目及其所有依赖项。dotnet msbuild - Builds a project and all of its dependencies. 注意:如果有多个解决方案或项目文件,可能需要指定一个。Note: A solution or project file may need to be specified if there are multiple.


dotnet msbuild <MSBUILD_ARGUMENTS>

dotnet msbuild -h


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 projects 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 -restoreThe dotnet build command is equivalent to dotnet msbuild -restore. 如果不想生成项目,并且拥有要运行的特定目标,请使用 dotnet builddotnet msbuild 并指定目标。When you don't want to build the project and you have a specific target you want to run, use dotnet build or dotnet msbuild and specify the target.


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

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

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

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

    dotnet msbuild -preprocess
    dotnet msbuild -preprocess:<fileName>.xml