Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core - how does the 'dotnet publish' command work?

I have a solution with some projects targeting .NET Standard 2.0 and a console application project targeting .NET Core 2.1.

I set "myFolder" as the output folder. Building from Visual Studio, I get all DLL files in:

  • "myFolder\netstandard2.0"
  • "myFolder\netcoreapp2.1"

I get the same using the "dotnet build" command. Now I need my console application's EXE file. So I use the "dotnet publish -c Release -r win-x64 MySolution.sln" command.

Now I get this new directory, "myFolder\netcoreapp2.1\win-x64", where I find all DLL files and the console application's EXE file.

Not enough!

I find one directory more, "myFolder\netcoreapp2.1\win-x64\publish", where I find again all DLL files and the console application's EXE file.

Which meaning do they have? I read the command documentation, but I didn't find my answer.

like image 245
Lorenzo Isidori Avatar asked Sep 20 '18 09:09

Lorenzo Isidori


People also ask

What is the difference between the dotnet pack and dotnet publish commands?

dotnet pack : The output is a package that is meant to be reused by other projects. dotnet publish : The output is mean to be deployed / "shipped" - it is not a single "package file" but a directory with all the project's output.

What is self contained publish .NET Core?

Publishing your app as self-contained produces an application that includes the . NET runtime and libraries, and your application and its dependencies. Users of the application can run it on a machine that doesn't have the . NET runtime installed.


1 Answers

Per the documentation

-o|--output <OUTPUT_DIRECTORY>

Specifies the path for the output directory. If not specified, it defaults to ./bin/[configuration]/[framework]/publish/ for a framework-dependent deployment or ./bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained deployment.

dotnet publish -c Release -r win-x64 --output ./MyTargetFolder MySolution.sln

like image 77
willwolfram18 Avatar answered Sep 19 '22 20:09

willwolfram18