Can we install net framework on linux

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:

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.

Читайте также:  Installing source files in linux

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.

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.

Читайте также:  Linux bootmgr is missing

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

Источник

Установка пакета SDK для .NET или среды выполнения .NET в Ubuntu 22.04

В этой статье описывается, как установить .NET в Ubuntu 22.04; поддерживаются .NET 6 и .NET 7.

Если вы хотите разрабатывать приложения .NET, установите пакет SDK (включает среду выполнения). Если нужно просто запустить приложения, установите среду выполнения. Если вы устанавливаете среду выполнения, мы рекомендуем установить среду выполнения ASP.NET Core, так как она включает в себя среды выполнения .NET и ASP.NET Core.

dotnet —list-sdks Используйте команды и dotnet —list-runtimes , чтобы узнать, какие версии установлены. Дополнительные сведения см. в статье Проверка того, установлена ли платформа .NET.

Установка диспетчера пакетов поддерживается только в архитектуре x64. Другие архитектуры, такие как Arm, должны устанавливать .NET другими способами, например с помощью Snap, скрипта установщика или с помощью двоичной установки вручную.

Дополнительные сведения об установке .NET без использования диспетчера пакетов см. в одной из следующих статей:

Платформа .NET доступна в веб-канале пакетов Ubuntu, а также в репозитории пакетов Майкрософт. Однако для установки .NET следует использовать только один или другой. Если вы хотите использовать репозиторий пакетов Майкрософт, см. статью Регистрация репозитория пакетов Майкрософт.

Поддерживаемые версии

Следующие версии .NET поддерживаются или доступны для Ubuntu 22.04:

Поддерживаемые версии .NET Доступно в веб-канале Ubuntu Доступно в веб-канале Майкрософт
7.0, 6.0 7.0, 6.0 7.0, 6.0, 3.1

Версии пакета SDK для .NET, предлагаемые Canonical, всегда находятся в диапазоне функций .1xx. Если вы хотите использовать более новый выпуск группы компонентов, используйте веб-канал Майкрософт, чтобы установить пакет SDK. Обязательно ознакомьтесь со сведениями в статье о пакете .NET в Linux , чтобы понять последствия переключения между веб-каналами репозитория.

Когда версия Ubuntu перестает поддерживаться, .NET больше не поддерживается с этой версией.

Следующие версии .NET больше не поддерживаются (❌).

  • .NET 5
  • .NET Core 3.1
  • .NET Core 3.0
  • .NET Core 2.2
  • .NET Core 2.1
  • .NET Core 2.0;

Установка .NET

Установка пакета SDK

Пакет SDK для .NET позволяет разрабатывать приложения с помощью .NET. При установке пакета SDK для .NET не нужно устанавливать соответствующую среду выполнения. Чтобы установить пакет SDK для .NET, выполните приведенные ниже команды.

sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-7.0 

Если появляется сообщение об ошибке, похожее на Не удалось найти пакет dotnet-sdk-7.0, см. раздел об устранении неполадок .

Установка среды выполнения

Среда выполнения ASP.NET Core позволяет запускать приложения, созданные с помощью версии .NET без поддержки среды выполнения. Приведенные ниже команды позволяют установить среду выполнения ASP.NET Core, которая больше всего совместима с .NET. В терминале выполните приведенные ниже команды.

sudo apt-get update && \ sudo apt-get install -y aspnetcore-runtime-7.0 

Если появляется сообщение об ошибке, похожее на Не удалось найти пакет aspnetcore-runtime-7.0, см. раздел об устранении неполадок .

В качестве альтернативы среде выполнения ASP.NET Core вы можете установить среду выполнения .NET без поддержки ASP.NET Core. Для этого в приведенной выше команде замените aspnetcore-runtime-7.0 на dotnet-runtime-7.0 .

sudo apt-get install -y dotnet-runtime-7.0 

Установка других версий

Другие версии .NET не поддерживаются в веб-каналах Ubuntu. Вместо этого используйте репозиторий пакетов Майкрософт.

Устранение неполадок

Если у вас возникли проблемы с установкой или даже запуском .NET, см. статью Устранение неполадок.

Зависимости

Если для установки используется диспетчер пакетов, эти библиотеки устанавливаются автоматически. Но если вы устанавливаете .NET вручную или публикуете автономное приложение, вам потребуется установить эти библиотеки:

  • libc6
  • libgcc1
  • libgcc-s1
  • libgssapi-krb5-2
  • libicu70
  • liblttng-ust1
  • libssl3
  • libstdc++6
  • libunwind8
  • zlib1g

Если приложение .NET использует сборку System.Drawing.Common , необходимо также установить libgdiplus. Так как System.Drawing.Common больше не поддерживается в Linux, это работает только в .NET 6 и требует настройки System.Drawing.EnableUnixSupport параметра конфигурации среды выполнения.

Вы можете установить последнюю версию libgdiplus , добавив репозиторий Mono в систему.

Дальнейшие действия

Источник

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