what is major difference between dotnet publish and dotnet pack

Lost picture Lost · May 22, 2017 · Viewed 7.6k times · Source

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.

Answer

t0mm13b picture t0mm13b · May 22, 2017

dotnet pack - Produces a NuGet package of your code.

That is the key difference - this will enable to publish to http://nuget.org, or to a nuget server that can be pulled down by other developers, or even for use with Octopus Deploy.

dotnet publish - Produces a .NET framework-dependent or self-contained application.

Keyword is "self-contained", a installer perhaps, or a folder that can be deployed by copying/pasting between hosts.