Install .NET SDK or .NET Runtime on Ubuntu 18.04

This article discusses how to install .NET on Ubuntu 18.04; .NET 6 and .NET 7 are supported.

Install the SDK (which includes the runtime) if you want to develop .NET apps. Or, if you only need to run apps, install the Runtime. If you're installing the Runtime, we suggest you install the ASP.NET Core Runtime as it includes both .NET and ASP.NET Core runtimes.

Use the dotnet --list-sdks and dotnet --list-runtimes commands to see which versions are installed. For more information, see How to check that .NET is already installed.

Important

Using a package manager to install .NET from the Microsoft package feed only supports the x64 architecture. Other architectures, such as Arm, aren't supported by the Microsoft package feed.

For more information on installing .NET without a package manager, see one of the following articles:

Supported versions

The following versions of .NET are supported or available for Ubuntu 18.04:

Supported .NET versions Available in Ubuntu feed Available in Microsoft feed
7.0, 6.0 None 7.0. 6.0, 5.0, 3.1, 2.2, 2.1

When an Ubuntu version falls out of support, .NET is no longer supported with that version.

The following versions of .NET are ❌ no longer supported:

  • .NET 5
  • .NET Core 3.1
  • .NET Core 3.0
  • .NET Core 2.2
  • .NET Core 2.1
  • .NET Core 2.0

Add the Microsoft package repository

Installing with APT can be done with a few commands. Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.

Open a terminal and run the following commands:

wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following commands:

sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-7.0

Important

If you receive an error message similar to Unable to locate package dotnet-sdk-7.0, see the troubleshooting section.

Install the runtime

The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn't provide the runtime. The following commands install the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following commands:

sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-7.0

Important

If you receive an error message similar to Unable to locate package aspnetcore-runtime-7.0, see the troubleshooting section.

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime, which doesn't include ASP.NET Core support: replace aspnetcore-runtime-7.0 in the previous command with dotnet-runtime-7.0:

sudo apt-get install -y dotnet-runtime-7.0

How to install other versions

All versions of .NET are available for download at https://dotnet.microsoft.com/download/dotnet, but require manual installation. You can try and use the package manager to install a different version of .NET. However, the requested version may not be available.

The packages added to package manager feeds are named in a hackable format, for example: {product}-{type}-{version}.

  • product
    The type of .NET product to install. Valid options are:

    • dotnet
    • aspnetcore
  • type
    Chooses the SDK or the runtime. Valid options are:

    • sdk (only available for the dotnet product)
    • runtime
  • version
    The version of the SDK or runtime to install. This article will always give the instructions for the latest supported version. Valid options are any released version, such as:

    • 8.0
    • 6.0
    • 3.1
    • 2.1

    It's possible the SDK/runtime you're trying to download is not available for your Linux distribution. For a list of supported distributions, see Install .NET on Linux.

Examples

  • Install the ASP.NET Core 8.0 runtime: aspnetcore-runtime-8.0
  • Install the .NET Core 2.1 runtime: dotnet-runtime-2.1
  • Install the .NET 5 SDK: dotnet-sdk-5.0
  • Install the .NET Core 3.1 SDK: dotnet-sdk-3.1

Package missing

If the package-version combination doesn't work, it's not available. For example, there isn't an ASP.NET Core SDK, the SDK components are included with the .NET SDK. The value aspnetcore-sdk-8.0 is incorrect and should be dotnet-sdk-8.0. For a list of Linux distributions supported by .NET, see .NET dependencies and requirements.

Troubleshooting

If you run into issues installing or even running .NET, see Troubleshooting.

Dependencies

When you install with a package manager, these libraries are installed for you. But, if you manually install .NET or you publish a self-contained app, you'll need to make sure these libraries are installed:

  • libc6
  • libgcc1
  • libgssapi-krb5-2
  • libicu60
  • libssl1.1
  • libstdc++6
  • zlib1g

Dependencies can be installed with the apt install command. The following snippet demonstrates installing the zlib1g library:

sudo apt install zlib1g

If the .NET app uses the System.Drawing.Common assembly, libgdiplus will also need to be installed. Because System.Drawing.Common is no longer supported on Linux, this only works on .NET 6 and requires setting the System.Drawing.EnableUnixSupport runtime configuration switch.

You can install a recent version of libgdiplus by adding the Mono repository to your system.

Next steps