Here I'm going to post whatever that is interesting for me. All things about programming using JavaScript and ASP.NET Core. And something else.

A blog about ASP.Net Core and JavaScript

Ready to get published...

Suppose, you need to deploy your ASP.NET application to the hosting under, let's say, CentOS 7 Linux operating system. As the official documentation says, you have to "Publish the app as a self-contained deployment in Release configuration for the CentOS 7 runtime (centos.7-x64)". It looks quite simple. But to do such publishing, you have to perform some investigations and read a lot of chunks of different articles.

Here, in this post, I suggest a simple step-by-step solution on how to publish your app with easy.

So, let's start.

Step 1. Adding runtime identifiers to the project file

Suppose, you have finished developing an ASP.NET Core web application. And you know that it will be running in the CentOS 7 runtime. So, you need to add the centos.7-x64 runtime identifier to your .csproj project file.

To do this, create a <RuntimeIdentifiers> tag in the <PropertyGroup> section of your .csproj file. Inside it specify the runtime identifiers (RID) separated by semicolons for each platform that you target. You can find  RID catalog in the official documentation.

Example of such .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
    <Folder Include="wwwroot\" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />


Step 2. Running the dotnet publish command

In the command line move to your project directory (containing .csproj file) and run the next command:

dotnet publish -c Release -r centos.7-x64 --self-contained

This command tells the dotnet to build release configuration of your project and copy resulting assembly with all dependencies including ASP.NET Core libraries to the ./bin/Release/netcoreapp2.0/centos.7-x64/publish folder.

When deploying for the first time, you should copy all contents of this folder including the subfolders to the host Linux environment.

Next times, until the dependencies updated, you can deploy only your files: compiled *.dll-s, views, and whatever changed.