Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

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

  • 2024-11-11
Feedback

In this article

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, seeInstall .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 theASP.NET Core Runtime as it includes both .NET and ASP.NET Core runtimes.

Use thedotnet --list-sdks anddotnet --list-runtimes commands to see which versions are installed. For more information, seeHow 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
9 (STS)7
8 (LTS)6 (LTS)
5
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 whenmanually 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:

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

RPM dependencies

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

  • krb5-libs
  • libicu
  • openssl-libs

DEB dependencies

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

  • libc6
  • libgcc1
  • libgssapi-krb5-2
  • libicu70
  • libssl3
  • libstdc++6
  • zlib1g

Scripted install

Thedotnet-install scripts are used for automation and non-admin installs of theSDK andRuntime. You can download the script fromhttps://dot.net/v1/dotnet-install.sh. When .NET is installed in this way, you must install the dependencies required by your Linux distribution. Use the links in theInstall .NET on Linux article for your specific Linux distribution.

Important

Bash is required to run the script.

You can download the script withwget:

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

Or, withcurl:

curl -L https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh

Before running this script, make sure you grant permission for this script to run as an executable:

chmod +x ./dotnet-install.sh

The script defaults to installing the latestlong term support (LTS) SDK version, which is .NET 8. To install the latest release, which might 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 9.0 SDK.

./dotnet-install.sh --channel 9.0

For more information, seedotnet-install scripts reference.

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

To learn how to use the .NET CLI, see.NET CLI overview.

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 abinary 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 theexport command to setDOTNET_ROOT to the extracted folder's location and then ensure .NET is in PATH. ExportingDOTNET_ROOT makes the .NET CLI commands available in the terminal. For more information about .NET environment variables, see.NET SDK and CLI environment variables.

Different versions of .NET can be extracted to the same folder, which coexist side-by-side.

Example

The following commands use Bash to set the environment variableDOTNET_ROOT to the current working directory followed by.dotnet. That directory is created if it doesn't exist. TheDOTNET_FILE environment variable is the filename of the .NET binary release you want to install. This file is extracted to theDOTNET_ROOT directory. Both theDOTNET_ROOT directory and itstools subdirectory are added to thePATH environment variable.

Important

If you run these commands, remember to change theDOTNET_FILE value to the name of the .NET binary you downloaded.

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

You can install more than one version of .NET in the same folder.

You can also install .NET to the home directory identified by theHOME variable or~ path:

export DOTNET_ROOT=$HOME/.dotnet

To learn how to use the .NET CLI, see.NET CLI overview.

Verify downloaded binaries

After downloading an installer or binary release, 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 the file from an official download page, the checksum for the file is displayed in a text box. Select theCopy button to copy the checksum value to your clipboard.

The .NET download page with checksum

Use thesha512sum command to print the checksum of the file you've downloaded. For example, the following command reports the checksum of thedotnet-sdk-8.0.100-linux-x64.tar.gz file:

$ sha512sum dotnet-sdk-8.0.100-linux-x64.tar.gz13905ea20191e70baeba50b0e9bbe5f752a7c34587878ee104744f9fb453bfe439994d38969722bdae7f60ee047d75dda8636f3ab62659450e9cd4024f38b2a5  dotnet-sdk-8.0.100-linux-x64.tar.gz

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

Important

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 8 on GitHub athttps://github.com/dotnet/core/tree/main/release-notes/8.0#releases contains a section namedReleases. The table in that section links to the downloads and checksum files for each .NET 8 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 8.0.100, which is in the .NET 8.0.0 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. Right-click on theChecksum link, and copy the link to your clipboard.

  5. Open a terminal.

  6. Usecurl -O {link} to download the checksum file.

    Replace the link in the following command with the link you copied.

    curl -O https://builds.dotnet.microsoft.com/dotnet/checksums/8.0.0-sha.txt
  7. With both the checksum file and the .NET release file downloaded to the same directory, use thesha512sum -c {file} --ignore-missing command to validate the downloaded file.

    When validation passes, you see the file printed with theOK status:

    $ sha512sum -c 8.0.0-sha.txt --ignore-missingdotnet-sdk-8.0.100-linux-x64.tar.gz: OK

    If you see the file marked asFAILED, the file you downloaded isn't valid and shouldn't be used.

    $ sha512sum -c 8.0.0-sha.txt --ignore-missingdotnet-sdk-8.0.100-linux-x64.tar.gz: FAILEDsha512sum: WARNING: 1 computed checksum did NOT matchsha512sum: 8.0.0-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 many different shells available for Linux and each has a different profile. For example:

  • Bash Shell:~/.bash_profile or~/.bashrc
  • Korn Shell:~/.kshrc or.profile
  • Z Shell:~/.zshrc or.zprofile

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
  • PATH

    This variable should include both theDOTNET_ROOT folder and theDOTNET_ROOT/tools folder:

    export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

Next steps

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo