All docs
V20.1
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Publish a .NET Core Application

  • 3 minutes to read

This article describes how to deploy a .NET Core application. The following deployment types are available:

Deployment Type Description
Framework-Dependent Deployment Creates a cross-platform DLL that can run on machines with the .NET Core runtime installed.
Framework-Dependent Executable Creates a platform-specific executable that can run on machines with the .NET Core runtime installed.
Self-Contained Deployment Creates a platform-specific executable that includes a local copy of the .NET Core runtime. The target system does not need the .NET Core runtime installed.

See the .NET Core application deployment topic for more information on application deployment types.

Deploy with CLI Tools

Use the dotnet publish command to publish a .NET Core application from the command line.

# Framework-dependent executable
dotnet publish -c Release

# Self-contained deployment
dotnet publish -c Release -r <RID> --self-contained true

-r <RID> Specifies the target platform where the application should run: win-x86, win-x64, linux-x64, osx-x64, etc.

See the .NET Core Runtime Identifier catalog.

--self-contained true Publishes the .NET Core runtime with the application so the target machine does not need the runtime installed.

Deploy with Visual Studio

  1. Right-click the project's name in the Solution Explorer and select Publish....

    Net_Core_VS_Publish

  2. In the invoked dialog, select Folder as a publish target, enter a path to the target folder and click Create Profile.

Net_Core_VS_Create_Profile_NetCore3

  1. Click Edit in the Publish pane to invoke the Profile Settings dialog.

Net_Core_VS_Edit_Profile_NetCore3

In the dialog, select the deployment mode and target platform, and save the profile.

Net_Core_VS_Profile_Settings_NetCore3

  1. Click Publish to publish your application to the target folder.

    Net_Core_VS_Publish

Deployment Options for .NET Core 3

Single Executable

You can pack your application and its dependencies (including the .NET Core 3 runtime) into a single executable as described below.

Method 1 (Edit the project file)

Specify the Runtime Identifier and set the PublishSingleFile option to true in your project file:

<PropertyGroup>
  <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  <PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>

Method 2 (Use the command line)

Run the dotnet publish command with the following parameters:

dotnet publish -r win-x64 /p:PublishSingleFile=true

As a result, the publish directory contains a single .exe and a .pdb file.

Net_Core_Single_Executable

Ready to Run Images

You can compile a .NET Core 3 application in a ReadyToRun (R2R) format to improve the application startup time.

R2R binaries contain intermediate language (IL) and native code (similar to what the just-in-time compiler produces). This native code reduces the JIT compiler workload during application startup.

To publish an application in the R2R format, set the PublishReadyToRun option to true in your project file:

<PropertyGroup>
  <PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

R2R format is only available for self-contained apps that target specific runtime environments (such as Windows x86 or Windows x64).