What is the main difference between dotnet publishing and dotnet package

What is the main difference between dotnet pack and publish ?

From the Microsoft description, I understand that pack creates a package, and publish creates a package + DLL.

It's right? If so, then why not just use publish and not use the DLL file if it is not needed.

+15
source share
3 answers

dotnet pack - Creates a NuGet package for your code.

This is the key difference - it will allow publishing on http://nuget.org or on the Nuget server, which can be removed by other developers, or even for use with Octopus Deploy.

dotnet publish - Publish a .NET dependent or standalone application.

The keyword is β€œstandalone”, possibly an installer, or a folder that can be expanded by copying / pasting between hosts.

+12
source

Addendum to @ t0mm13b answer:

dotnet pack : exit is a package that is designed to be reused by other projects.

dotnet publish : the output is average for deployment / "shipment" - this is not one "batch file", but a directory with all the project output.

+4
source

In fact, when we use the pack command, it creates a package, and when we use the publish command, it creates a folder that can be copied and executed anywhere from it. But what makes the pack command unique is that the package is updated on the nuget server without loading its dependencies. Its dependencies are updated in the project that selects the package when we run the dotnet restore command, and this does not apply to the case of dotnet publish , since it contains third-party dependencies packaged in the package.

0
source

Source: https://habr.com/ru/post/1268114/


All Articles