英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论