dotnet Release build vs dotnet publish

huangapple go评论80阅读模式
英文:

dotnet Release build vs dotnet publish

问题

以下是翻译好的部分:

"dotnet publish MyApi.csproj -o output" 与 "dotnet build MyApi.csproj -c release -o output" 之间的区别是什么?

尝试找到在我的YAML管道中用于.zip部署工件的最“理想”命令。我应该使用哪个?

英文:

What is the difference between

dotnet publish MyApi.csproj -o output

and

dotnet build MyApi.csproj -c release -o output

Trying to find the most "ideal" command to use in my yaml pipeline for .zip artifact deploy. Which one should I use?

答案1

得分: 2

你应该使用 dotnet publish 来获取一个包含需要发布的文件的“干净”文件夹。

当你使用 dotnet build 时,bin\Release 文件夹可能包含不需要发布的额外文件,如中间构建文件。虽然有方法来避免中间文件的干扰,但使用 dotnet publish 可以完全避免这个问题。

注意:dotnet publish 还接受 -c 标志,允许您像使用 dotnet build 命令一样指定配置。

英文:

You should use dotnet publish to get a "clean" folder with the files that need to be published.

When you use dotnet build, the bin\Release folder may contain additional files that do not need to be published, such as the intermediate build files. While there are solutions to keep the intermediate files out of the way, using dotnet publish lets you avoid this issue altogether.

Note: dotnet publish also takes the -c flag, which lets you specify the configuration the way you did with your dotnet build command.

huangapple
  • 本文由 发表于 2023年8月4日 23:16:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76837225.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定