Net core runtime linux

Install .NET SDK or .NET Runtime on Ubuntu 22.04

This article discusses how to install .NET on Ubuntu 22.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.

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:

.NET is available in the Ubuntu packages feed, as well as the Microsoft package repository. However, you should only use one or the other to install .NET. If you want to use the Microsoft package repository, see How to register the Microsoft package repository.

Supported versions

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

Supported .NET versions Available in Ubuntu feed Available in Microsoft feed
7.0, 6.0 7.0, 6.0 7.0, 6.0, 3.1

.NET SDK versions offered by Canonical are always in the .1xx feature band. If you want to use a newer feature band release, use the Microsoft feed to install the SDK. Make sure you review the information in the .NET package mix ups on Linux article to understand the implications of switching between repository feeds.

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

Install .NET

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.

Читайте также:  How to make zip linux

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

Other versions of .NET aren’t supported in the Ubuntu feeds. Instead, use the Microsoft package repository.

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
  • libgcc-s1
  • libgssapi-krb5-2
  • libicu70
  • liblttng-ust1
  • libssl3
  • libstdc++6
  • libunwind8
  • 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

Источник

Install .NET on Linux by using an install script or by extracting binaries

This article demonstrates how to install the .NET SDK or the .NET Runtime on Linux by using the install script or by extracting the binaries. For a list of distributions that support the built-in package manager, see Install .NET on Linux.

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.

.NET releases

There are two types of supported releases, Long Term Support (LTS) releases or 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 3 years. STS releases get free support and patches for 18 months. For more information, see .NET Support Policy.

The following table lists the support status of each version of .NET (and .NET Core):

✔️ Supported ❌ Unsupported
7 (STS) 5
6 (LTS) 3.1
3.0
2.2
2.1
2.0
1.1
1.0

Dependencies

It’s possible that when you install .NET, specific dependencies may not be installed, such as when manually installing. The following list details Linux distributions that are supported by Microsoft and have dependencies you may need to install. Check the distribution page for more information:

Читайте также:  Linux amd drivers open source

For generic information about the dependencies, see Self-contained Linux apps.

RPM dependencies

If your distribution wasn’t previously listed, and is RPM-based, you may need the following dependencies:

If the target runtime environment’s OpenSSL version is 1.1 or newer, you’ll need to install compat-openssl10.

DEB dependencies

If your distribution wasn’t previously listed, and is debian-based, you may need the following dependencies:

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

Common dependencies

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 usually install a recent version of libgdiplus by adding the Mono repository to your system.

Scripted install

The dotnet-install scripts are used for automation and non-admin installs of the SDK and Runtime. You can download the script from https://dot.net/v1/dotnet-install.sh. When .NET is installed in this way, you’ll need to install dependencies required by your Linux distribution. Use the links in the Install .NET on Linux article for your specific Linux distribution.

Bash is required to run the script.

You can download the script with wget :

wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh 

Before running this script, you’ll need to grant permission for this script to run as an executable:

The script defaults to installing the latest long term support (LTS) SDK version, which is .NET 6. To install the latest release, which may not be an (LTS) version, use the —version latest parameter.

./dotnet-install.sh --version latest 

To install .NET Runtime instead of the SDK, use the —runtime parameter.

./dotnet-install.sh --version latest --runtime aspnetcore 

You can install a specific major version with the —channel parameter to indicate the specific version. The following command installs .NET 7.0 SDK.

./dotnet-install.sh --channel 7.0 

To enable .NET on the command line, see Set environment variables system-wide.

Manual install

As an alternative to the package managers, you can download and manually install the SDK and runtime. Manual installation is commonly used as part of continuous integration testing or on an unsupported Linux distribution. For a developer or user, it’s better to use a package manager.

Download a binary release for either the SDK or the runtime from one of the following sites. The .NET SDK includes the corresponding runtime:

Extract the downloaded file and use the export command to set DOTNET_ROOT to the extracted folder’s location and then ensure .NET is in PATH. Exporting DOTNET_ROOT makes the .NET CLI commands available in the terminal. For more information about .NET environment variables, see .NET SDK and CLI environment variables.

Alternatively, after downloading the .NET binary, the following commands may be run from the directory where the file is saved to extract the runtime. Running the following commands makes the .NET CLI commands available at the terminal and sets the required environment variables. Remember to change the DOTNET_FILE value to the name of the downloaded binary:

DOTNET_FILE=dotnet-sdk-7.0.100-linux-x64.tar.gz export DOTNET_ROOT=$(pwd)/.dotnet mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT" export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools 

The preceding install script approach allows installing different versions into separate locations so you can choose explicitly which one to use by which app.

Читайте также:  Usr include linux version h

Verify downloaded binaries

After downloading an installer, verify it to make sure that the file hasn’t been changed or corrupted. You can verify the checksum on your computer and then compare it to what was reported on the download website.

When you download an installer or binary from an official download page, the checksum for the file is displayed. Select the Copy button to copy the checksum value to your clipboard.

The .NET download page with checksum

Use the sha512sum command to print the checksum of the file you’ve downloaded. For example, the following command reports the checksum of the dotnet-sdk-7.0.304-linux-x64.tar.gz file:

$ sha512sum dotnet-sdk-7.0.304-linux-x64.tar.gz f4b7d0cde432bd37f445363b3937ad483e5006794886941e43124de051475925b3cd11313b73d2cae481ee9b8f131394df0873451f6088ffdbe73f150b1ed727 dotnet-sdk-7.0.304-linux-x64.tar.gz 

Compare the checksum with the value provided by the download site.

Even though a Linux file is shown in these examples, this information equally applies to macOS.

Use a checksum file to validate

The .NET release notes contain a link to a checksum file you can use to validate your downloaded file. The following steps describe how to download the checksum file and validate a .NET install binary:

  1. The release notes page for .NET 7 on GitHub at https://github.com/dotnet/core/tree/main/release-notes/7.0 contains a section named Releases. The table in that section links to the downloads and checksum files for each .NET 7 release: The github release notes version table for .NET
  2. Select the link for the version of .NET that you downloaded. The previous section used .NET SDK 7.0.304, which is in the .NET 7.0.7 release.
  3. In the release page, you can see the .NET Runtime and .NET SDK version, and a link to the checksum file: The download table with checksums for .NET
  4. Copy the link to the checksum file.
  5. Use the following script, but replace the link to download the appropriate checksum file:
curl -O https://dotnetcli.blob.core.windows.net/dotnet/checksums/7.0.7-sha.txt 
$ sha512sum -c 7.0.7-sha.txt --ignore-missing dotnet-sdk-7.0.304-linux-x64.tar.gz: OK 

If you see the file marked as FAILED, the file you downloaded isn’t valid and shouldn’t be used.

$ sha512sum -c 7.0.7-sha.txt --ignore-missing dotnet-sdk-7.0.304-linux-x64.tar.gz: FAILED sha512sum: WARNING: 1 computed checksum did NOT match sha512sum: 7.0.7-sha.txt: no file was verified 

Set environment variables system-wide

If you used the previous install script, the variables set only apply to your current terminal session. Add them to your shell profile. There are a number of different shells available for Linux and each has a different profile. For example:

Set the following two environment variables in your shell profile:

    DOTNET_ROOT This variable is set to the folder .NET was installed to, such as $HOME/.dotnet :

export DOTNET_ROOT=$HOME/.dotnet 
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools 

Next steps

Источник

Оцените статью
Adblock
detector