Sona
Sona

Reputation: 23

Command to build and publish the .NET Core Console application

Is it possible to build and publish the code at the same time using .net core 2.0

I have console application which I have created in .net and inside the same solution have some libraries which is targeting to framework 4.5. I am looking for the command which can build and at the same time publish as Self contained.

Can anyone please suggest me the command which can build and publish at the same time as Self Contained.

Upvotes: 1

Views: 1300

Answers (1)

willwolfram18
willwolfram18

Reputation: 1887

The dotnet publish command has two parameters that you'll need to specify:

  • The --self-contained flag does exactly what you think; tells the command to publish an application that is totally self contained.
  • The -r|--runtime flag specifies which target operating system the application should be able to run on.

You can find more details in the full docs here: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore21#arguments

Upvotes: 1

Related Questions