what is major difference between dotnet publish and dotnet pack

Viewed 9757

What is the major difference between dotnet pack and publish?

From Microsoft's description, my understanding is that pack creates a package while publish creates package + DLL.

Is this correct? If so, why not just always use publish and not use the DLL file if it is not needed.

3 Answers

Basically, when we use the pack command, it creates a package; when we use the publish command, it creates a folder that can be copied and executed from anywhere.

What makes pack command unique is that the package gets updated to the nuget server without uploading its dependencies. Its dependencies are updated in the project which fetches the package when we run dotnet restore. This is not with the case of dotnet publish, as it contains third-party dependencies packed in the bundle.

Related