17

I asked here how to create a .exe to run on Windows and learned the command

dotnet publish --configuration Release --runtime win-x64

This created files in the \bin\Release\netcoreapp2.0\win-x64 folder as well as a subfolder called publish which contains a copy of the same files.

Why are duplicate files created? ( In the Win-x64 folder and in the publish folder)

enter image description here

enter image description here

Kirsten
  • 15,730
  • 41
  • 179
  • 318

1 Answers1

14

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.

Output binaries provided by build stage are then copied to publish directory together with required dependencies. You probably could expect that binaries are built right away to publish directory without necessity to duplicate them from build directory to publish. Well, it's a fair assumption. However it will harm separation of different stages - build and publish. Also as far as HDD resource is very cheap now, it shouldn't be a big issue.

CodeFuller
  • 30,317
  • 3
  • 63
  • 79
  • 1
    Thank you. I have a similar question at https://stackoverflow.com/questions/49959701/what-should-i-do-with-the-netcoreapp2-0-folder-created-by-publish – Kirsten Apr 21 '18 at 19:57
  • This also happens when publishing an api with duplicate files being stored in a folder called netcoreapp2.0 – Kirsten Apr 21 '18 at 20:38
  • 1
    @CodeFuller why not clean up the duplicate items after the build to avoid this kind of confusion? Is there a need for them afterwards? I.e. would it improve build/publish performance on the next build/publish – Jacques Jan 28 '21 at 12:56