为什么dotnet publish创建相同文件的2个副本?

Kir*_*eed 5 .net-core

在这里询问 如何创建在Windows上运行的.exe,并了解了该命令

dotnet publish --configuration Release --runtime win-x64
Run Code Online (Sandbox Code Playgroud)

这将在\ bin \ Release \ netcoreapp2.0 \ win-x64文件夹以及一个名为publish的子文件夹中创建文件,该子文件夹包含相同文件的副本。

为什么要创建重复文件?(在Win-x64文件夹和publish文件夹中)

在此处输入图片说明

在此处输入图片说明

Cod*_*ler 9

dotnet publish builds the project before copying binaries to the output directory. The files you see in bin\Release\netcoreapp2.0\win-x64 directory are the result of dotnet build command. You could check it by running following command:

dotnet build --configuration Release --runtime win-x64

You will see exactly the same files as if you run dotnet publish --configuration Release --runtime win-x64.

然后将构建阶段提供的输出二进制文件连同所需的依赖项一起复制到发布目录。您可能会期望立即构建二进制文件以发布目录,而无需将它们从构建目录复制到发布。嗯,这是一个公平的假设。然而,它会损害不同阶段的分离——构建和发布。此外,就硬盘资源现在非常便宜而言,这应该不是什么大问题。