- Install the .NET SDK or the .NET Runtime on Debian
- Supported distributions
- Install preview versions
- Remove preview versions
- Debian 11
- Install the SDK
- Install the runtime
- Debian 10
- Install the SDK
- Install the runtime
- How to install other versions
- Examples
- Package missing
- Use APT to update .NET
- Troubleshooting
- Unable to find package
- Unable to locate \ Some packages could not be installed
- Failed to fetch
- Dependencies
- Next steps
Install the .NET SDK or the .NET Runtime on Debian
This article describes how to install .NET on Debian. When a Debian version falls out of support, .NET is no longer supported with that version. However, these instructions may help you to get .NET running on those versions, even though it isn’t 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.
Package manager installs are only supported on the x64 architecture. Other architectures, such as Arm, must install .NET by some other means such as with Snap, an installer script, or through a manual binary installation.
For more information on installing .NET without a package manager, see one of the following articles:
Supported distributions
The following table is a list of currently supported .NET releases and the versions of Debian they’re supported on. These versions remain supported until either the version of .NET reaches end-of-support or the version of Debian reaches end-of-life.
Debian | .NET |
---|---|
11 | 7, 6 |
10 | 7, 6 |
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
Install preview versions
Preview and release candidate versions of .NET aren’t available in package repositories. You can install previews and release candidates of .NET in one of the following ways:
Remove preview versions
When using a package manager to manage your installation of .NET, you may run into a conflict if you’ve previously installed a preview release. The package manager may interpret the non-preview release as an earlier version of .NET. To install the non-preview release, first uninstall the preview versions. For more information about uninstalling .NET, see How to remove the .NET Runtime and SDK.
Debian 11
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/debian/11/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
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
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
Debian 10
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/debian/10/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
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
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
The type of .NET product to install. Valid options are:- dotnet
- aspnetcore
- sdk (only available for the dotnet product)
- runtime
- 7.0
- 5.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 7.0 runtime: aspnetcore-runtime-7.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-7.0 is incorrect and should be dotnet-sdk-7.0 . For a list of Linux distributions supported by .NET, see .NET dependencies and requirements.
Use APT to update .NET
When a new patch release is available for .NET, you can simply upgrade it through APT with the following commands:
sudo apt-get update sudo apt-get upgrade
If you’ve upgraded your Linux distribution since installing .NET, you may need to reconfigure the Microsoft package repository. Run the installation instructions for your current distribution version to upgrade to the appropriate package repository for .NET updates.
Troubleshooting
This section provides information on common errors you may get while using APT to install .NET.
Unable to find package
Package manager installs are only supported on the x64 architecture. Other architectures, such as Arm, must install .NET by some other means such as with Snap, an installer script, or through a manual binary installation.
For more information on installing .NET without a package manager, see one of the following articles:
Unable to locate \ Some packages could not be installed
If you receive an error message similar to Unable to locate package or Some packages could not be installed, run the following commands.
There are two placeholders in the following set of commands.
- This represents the .NET package you’re installing, such as aspnetcore-runtime-7.0 . This is used in the following sudo apt-get install command.
- This represents the distribution version you’re on. This is used in the wget command below. The distribution version is the numerical value, such as 20.04 on Ubuntu or 10 on Debian.
First, try purging the package list:
sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update
Then, try to install .NET again. If that doesn’t work, you can run a manual install with the following commands:
sudo apt-get install -y gpg wget -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o microsoft.asc.gpg sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ wget https://packages.microsoft.com/config/debian//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 update && \ sudo apt-get install -y
Failed to fetch
While installing the .NET package, you may see an error similar to Failed to fetch . File has unexpected size . Mirror sync in progress? . This error could mean that the package feed for .NET is being upgraded with newer package versions, and that you should try again later. During an upgrade, the package feed shouldn’t be unavailable for more than 30 minutes. If you continually receive this error for more than 30 minutes, please file an issue at https://github.com/dotnet/core/issues.
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
- libgcc-s1
- libgssapi-krb5-2
- libicu63 (for 10.x)
- libicu67 (for 11.x)
- libssl1.1
- libstdc++6
- 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