Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes how to install the .NET Runtime snap package. .NET Runtime snap packages are provided by and maintained by Canonical. Snaps are a great alternative to the package manager built into your Linux distribution. If you need to install the SDK, see Install .NET SDK with Snap.
A snap is a bundle of an app and its dependencies that works across many different Linux distributions. Snaps are discoverable and installable from the Snap Store. For more information about Snap, see Get started.
Caution
Snap installations of .NET may have problems running .NET tools. If you wish to use .NET tools, we recommend that you install .NET using the dotnet-install script or the package manager for the particular Linux distribution.
Prerequisites
- Linux distribution that supports snap.
snapdthe snap daemon.
Your Linux distribution might already include snap. Try running snap from a terminal to see if the command works. For a list of supported Linux distributions, and instructions on how to install snap, see Installing snapd.
.NET releases
Microsoft publishes .NET under two different support policies, Long Term Support (LTS) and Standard Term Support (STS). The quality of all releases is the same. The only difference is the length of support. LTS releases get free support and patches for three years. STS releases get free support and patches for two years. For more information, see .NET Support Policy.
The versions of .NET that are currently supported by Microsoft are:
- 11.0 (STS)—Support ends November 14, 2028.
- 10.0 (LTS)—Support ends November 14, 2028.
Other entities that build and release .NET might introduce different support policies. Be sure to check with them to understand how .NET is supported.
1. Install the runtime
The following steps install the .NET 10 runtime snap package:
Open a terminal.
Use
snap installto install the .NET Runtime snap package. For example, the following command installs the .NET 10 runtime.sudo snap install dotnet-runtime-100
Each .NET Runtime is published as an individual snap package. The following table lists the packages:
| .NET version | Snap package | .NET version supported by Microsoft |
|---|---|---|
| 11 (STS) | dotnet-runtime-110 |
Yes |
| 10 (LTS) | dotnet-runtime-100 |
Yes |
| 9 (STS) | dotnet-runtime-90 |
No |
| 8 (LTS) | dotnet-runtime-80 |
No |
| 7 (STS) | dotnet-runtime-70 |
No |
| 6 (LTS) | dotnet-runtime-60 |
No |
| 5 | dotnet-runtime-50 |
No |
| 3.1 | dotnet-runtime-31 |
No |
| 3.0 | dotnet-runtime-30 |
No |
| 2.2 | dotnet-runtime-22 |
No |
| 2.1 | dotnet-runtime-21 |
No |
2. Enable the dotnet command
Because Snap doesn't create an unversioned dotnet command, create a symbolic link to make dotnet available system-wide. Create this link only if you want to map the dotnet command to this specific Snap installation. If /usr/local/bin/dotnet already exists, remove it before creating the link; otherwise, ln -s fails.
sudo ln -s /snap/dotnet-runtime-100/current/usr/bin/dotnet /usr/local/bin/dotnet
Some runtime snaps expose a dotnet app for backwards compatibility. For example, with dotnet-runtime-80, you can instead enable the unversioned command with:
sudo snap alias dotnet-runtime-80.dotnet dotnet
Content-only snaps such as dotnet-runtime-90, dotnet-runtime-100, and dotnet-runtime-110 don't expose a dotnet app. For those packages, use the preceding symbolic-link instructions.
3. Export the install location
The DOTNET_ROOT environment variable is often used by tools to determine where .NET is installed. When .NET is installed through Snap, this environment variable isn't configured. You should configure the DOTNET_ROOT environment variable in your profile. The path uses the following format: /snap/{package}/current/usr/lib/dotnet. For example, if you installed the dotnet-runtime-100 snap, use the following command to set the environment variable to where .NET is located:
export DOTNET_ROOT=/snap/dotnet-runtime-100/current/usr/lib/dotnet
Export the environment variable permanently
The preceding export command only sets the environment variable for the terminal session in which it was run.
You can edit your shell profile to permanently add the commands. There are a number of different shells available for Linux and each has a different profile. For example:
- Bash Shell: ~/.bash_profile, ~/.bashrc
- Korn Shell: ~/.kshrc or .profile
- Z Shell: ~/.zshrc or .zprofile
Edit the appropriate source file for your shell and add export DOTNET_ROOT=/snap/dotnet-runtime-100/current/usr/lib/dotnet.
Troubleshooting
The dotnet terminal command doesn't work
Content-only .NET Runtime snaps, including dotnet-runtime-90, dotnet-runtime-100, and dotnet-runtime-110, don't create an unversioned dotnet command. To make the dotnet command available, create a symbolic link to the dotnet executable in the snap package:
sudo ln -s /snap/dotnet-runtime-100/current/usr/bin/dotnet /usr/local/bin/dotnet
Substitute dotnet-runtime-100 with the name of your runtime package. If /usr/local/bin/dotnet already exists, remove it before you create the link.
For a runtime snap that exposes a dotnet app, such as dotnet-runtime-80, you can use snap alias instead:
sudo snap alias dotnet-runtime-80.dotnet dotnet
Can't install Snap on WSL2
systemd must be enabled on the WSL2 instance before Snap can be installed.
Open
/etc/wsl.confin a text editor of your choice.Paste in the following configuration:
[boot] systemd=trueSave the file and restart the WSL2 instance through PowerShell. Use the
wsl.exe --shutdowncommand.
4. Use the .NET CLI
Open a terminal and type dotnet.
dotnet
You'll see output similar to the following:
Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
path-to-application:
The path to an application .dll file to execute.
To learn how to use the .NET CLI, see .NET CLI overview.