Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish console application via command line using specific publish profile

I try to build and publish my .NET Core applications on the command line using predefined publish profiles.

For a ASP.NET Core application this (taken from here) works:

dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=ReleaseFolder

But for a console application (where the publish profile is called FolderProfile, the following does not work:

dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile

It builds the project but does not publish it.

So how can I publish a console application using a predefined publish profile?

like image 343
Robert Hegner Avatar asked Nov 02 '25 03:11

Robert Hegner


1 Answers

Publish profile support is part of the web-SDK which is used by the web targets. ASP.NET Core applications typically use the Microsoft.NET.Sdk.Web wheres console applications use the Microsoft.NET.Sdk project.

Since console applications therefor don't include the web SDK's publishing support, you can only use the Publish target which generates deployable outputs. It is wrapped by the dotnet cli's dotnet publish command and can alternatively be used as msbuild /t:Publish. This publish command has no support for publish profiles since it is only a filesystem based operation.

like image 90
Martin Ullrich Avatar answered Nov 04 '25 19:11

Martin Ullrich