0

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.

Sona
  • 13
  • 3
  • 1
    Possible duplicate of [.Net Core how works dotnet publish command](https://stackoverflow.com/questions/52421644/net-core-how-works-dotnet-publish-command) – baruchiro Jul 30 '19 at 03:55
  • Do you only want to build and publish the single .net core project? (I'm bit confused about the reason you mentioned you have some libraries in the solution) You can use `dotnet publish xx.csproj ...` to specify the project you want to build and publish. – LoLance Jul 30 '19 at 15:50

1 Answers1

1

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

willwolfram18
  • 1,747
  • 13
  • 25