Skip to content
Advertisement

Publishing ASP.NET Core Applications on linux nginx server

When publishing an ASP.NET Core application to a Linux server running nginx, is it necessary to install the .NET Core runtime on the server?

Advertisement

Answer

One of the options when publishing a .NET Core application is self contained deployments which include a version of the .NET Core runtime.

They are described (in the above link) as:

For a self-contained deployment, you deploy your app and any required third-party dependencies along with the version of .NET Core that you used to build the app. Creating an SCD doesn’t include the native dependencies of .NET Core on various platforms, so these must be present before the app runs.

So your target machine will still need to have the libraries that .NET Core relies on, but it’s entirely possible to publish you application and not have the .NET Core runtime installed on your target server.

Creating a SCD, you need to make a few changes to your csproj

<PropertyGroup>
  <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
</PropertyGroup>

The above would inform MSBuild that you want to target 64 bit Windows 10 and OSX 11.10.

Then you can create a published version of your app for one of those run platforms by running the following commands:

dotnet publish -c Release -r win10-x64
dotnet publish -c Release -r osx.10.11-x64

(the first line creates a SCD for Windows 10 64 bit, and the second does the same for OSX 10.11 64 bit.

Source: Self-contained deployment without third-party dependencies

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement