Ubuntu 19.04 Package Manager - Install .NET Core

This article describes how to use a package manager to install .NET Core on Ubuntu 19.04. If you're installing the runtime, we suggest you install the ASP.NET Core runtime, as it includes both .NET Core and ASP.NET Core runtimes.

Register Microsoft key and feed

Before installing .NET, you'll need to:

  • Register the Microsoft key
  • register the product repository
  • Install required dependencies

This only needs to be done once per machine.

Open a terminal and run the following commands.

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

Install the .NET Core SDK

Update the products available for installation, then install the .NET Core SDK. In your terminal, run the following commands.

sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1

Important

If you receive an error message similar to Unable to locate package dotnet-sdk-3.1, see the Troubleshoot the package manager section.

Install the ASP.NET Core runtime

Update the products available for installation, then install the ASP.NET Core runtime. In your terminal, run the following commands.

sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install aspnetcore-runtime-3.1

Important

If you receive an error message similar to Unable to locate package aspnetcore-runtime-3.1, see the Troubleshoot the package manager section.

Install the .NET Core runtime

Update the products available for installation, then install the .NET Core runtime. In your terminal, run the following commands.

sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-runtime-3.1

Important

If you receive an error message similar to Unable to locate package dotnet-runtime-3.1, see the Troubleshoot the package manager section.

How to install other versions

The packages added to the package manager feeds are named in a hackable format: {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
    • 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:

    • 3.0
    • 2.2
    • 2.1

Examples

  • Install the .NET Core 2.2 SDK: dotnet-sdk-2.2
  • Install the ASP.NET Core 3.0 runtime: aspnetcore-runtime-3.0
  • Install the .NET Core 2.1 runtime: dotnet-runtime-2.1

Troubleshoot

If the package 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 Core SDK. The value aspnetcore-sdk-2.2 is incorrect and should be dotnet-sdk-2.2

Troubleshoot the package manager

If you receive an error message similar to Unable to locate package {the .NET Core package}, run the following commands.

sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install {the .NET Core package}

If that doesn't work, you can run a manual install with the following commands.

sudo apt-get install -y gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/ubuntu/19.04/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install {the .NET Core package}