|
| 1 | +--- |
| 2 | +title: Install .NET Core on Ubuntu 20.04 package manager - .NET Core |
| 3 | +description: Use a package manager to install .NET Core SDK and runtime on Ubuntu 20.04. |
| 4 | +author: thraka |
| 5 | +ms.author: adegeo |
| 6 | +ms.date: 04/15/2020 |
| 7 | +--- |
| 8 | + |
| 9 | +# Ubuntu 20.04 Package Manager - Install .NET Core |
| 10 | + |
| 11 | +[!INCLUDE [package-manager-switcher](./includes/package-manager-switcher.md)] |
| 12 | + |
| 13 | +This article describes how to use a package manager to install .NET Core on Ubuntu 20.04. |
| 14 | + |
| 15 | +[!INCLUDE [package-manager-intro-sdk-vs-runtime](includes/package-manager-intro-sdk-vs-runtime.md)] |
| 16 | + |
| 17 | +## Add Microsoft repository key and feed |
| 18 | + |
| 19 | +Before installing .NET, you'll need to: |
| 20 | + |
| 21 | +- Add the Microsoft package signing key to the list of trusted keys. |
| 22 | +- Add the repository to the package manager. |
| 23 | +- Install required dependencies. |
| 24 | + |
| 25 | +This only needs to be done once per machine. |
| 26 | + |
| 27 | +Open a terminal and run the following commands. |
| 28 | + |
| 29 | +```bash |
| 30 | +wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb |
| 31 | +sudo dpkg -i packages-microsoft-prod.deb |
| 32 | +``` |
| 33 | + |
| 34 | +## Install the .NET Core SDK |
| 35 | + |
| 36 | +Update the products available for installation, then install the .NET Core SDK. In your terminal, run the following commands. |
| 37 | + |
| 38 | +```bash |
| 39 | +sudo apt-get update |
| 40 | +sudo apt-get install apt-transport-https |
| 41 | +sudo apt-get update |
| 42 | +sudo apt-get install dotnet-sdk-3.1 |
| 43 | +``` |
| 44 | + |
| 45 | +> [!IMPORTANT] |
| 46 | +> If you receive an error message similar to **Unable to locate package dotnet-sdk-3.1**, see the [Troubleshoot the package manager](#troubleshoot-the-package-manager) section. |
| 47 | +
|
| 48 | +## Install the ASP.NET Core runtime |
| 49 | + |
| 50 | +Update the products available for installation, then install the ASP.NET Core runtime. In your terminal, run the following commands. |
| 51 | + |
| 52 | +```bash |
| 53 | +sudo apt-get update |
| 54 | +sudo apt-get install apt-transport-https |
| 55 | +sudo apt-get update |
| 56 | +sudo apt-get install aspnetcore-runtime-3.1 |
| 57 | +``` |
| 58 | + |
| 59 | +> [!IMPORTANT] |
| 60 | +> If you receive an error message similar to **Unable to locate package aspnetcore-runtime-3.1**, see the [Troubleshoot the package manager](#troubleshoot-the-package-manager) section. |
| 61 | +
|
| 62 | +## Install the .NET Core runtime |
| 63 | + |
| 64 | +Update the products available for installation, then install the .NET Core runtime. In your terminal, run the following commands. |
| 65 | + |
| 66 | +```bash |
| 67 | +sudo apt-get update |
| 68 | +sudo apt-get install apt-transport-https |
| 69 | +sudo apt-get update |
| 70 | +sudo apt-get install dotnet-runtime-3.1 |
| 71 | +``` |
| 72 | + |
| 73 | +> [!IMPORTANT] |
| 74 | +> If you receive an error message similar to **Unable to locate package dotnet-runtime-3.1**, see the [Troubleshoot the package manager](#troubleshoot-the-package-manager) section. |
| 75 | +
|
| 76 | +## How to install other versions |
| 77 | + |
| 78 | +[!INCLUDE [package-manager-switcher](./includes/package-manager-heading-hack-pkgname.md)] |
| 79 | + |
| 80 | +## Troubleshoot the package manager |
| 81 | + |
| 82 | +This section provides information on common errors you may get while using the package manager to install .NET Core. |
| 83 | + |
| 84 | +### Unable to locate |
| 85 | + |
| 86 | +If you receive an error message similar to **Unable to locate package {the .NET Core package}**, run the following commands. |
| 87 | + |
| 88 | +```bash |
| 89 | +sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb |
| 90 | +sudo apt-get update |
| 91 | +sudo apt-get install {the .NET Core package} |
| 92 | +``` |
| 93 | + |
| 94 | +If that doesn't work, you can run a manual install with the following commands. |
| 95 | + |
| 96 | +```bash |
| 97 | +sudo apt-get install -y gpg |
| 98 | +wget -O- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o microsoft.asc.gpg |
| 99 | +sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ |
| 100 | +wget https://packages.microsoft.com/config/ubuntu/20.04/prod.list |
| 101 | +sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list |
| 102 | +sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg |
| 103 | +sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list |
| 104 | +sudo apt-get install -y apt-transport-https |
| 105 | +sudo apt-get update |
| 106 | +sudo apt-get install {the .NET Core package} |
| 107 | +``` |
| 108 | + |
| 109 | +### Failed to fetch |
| 110 | + |
| 111 | +[!INCLUDE [package-manager-failed-to-fetch-deb](includes/package-manager-failed-to-fetch-deb.md)] |
0 commit comments