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:
|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.
--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
Right-click the project's name in the Solution Explorer and select Publish....
In the invoked dialog, select Folder as a publish target, enter a path to the target folder and click Create Profile.
- Click Edit in the Publish pane to invoke the Profile Settings dialog.
In the dialog, select the deployment mode and target platform, and save the profile.
Click Publish to publish your application to the target folder.
Deployment Options for .NET Core 3
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)
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.
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).