- Install .NET on Linux by using an install script or by extracting binaries
- .NET releases
- Dependencies
- RPM dependencies
- DEB dependencies
- Common dependencies
- Scripted install
- Manual install
- Set environment variables system-wide
- Christian Engvall
- Installing Visual Studio Code and ASP.NET Core on Linux Mint
- 1. Installing .NET CORE
- 2. Install Visual Studio Code
- 3. Install the C# Extension
- 4. Creating an ASP.NET Core Project
- Установка .NET в Linux с помощью скрипта установки или извлечения двоичных файлов
- Выпуски .NET
- Зависимости
- Зависимости RPM
- Зависимости DEB
- Общие зависимости
- Установка с помощью скрипта
- Установка вручную
- Настройка системных переменных среды
- Name already in use
- core / Documentation / linux-setup.md
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.
You can also install .NET with snap. For more information, see Install the .NET SDK or the .NET Runtime with Snap.
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.
If you’ve already installed the SDK or Runtime, 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
The following table lists the .NET (and .NET Core) releases:
вњ”пёЏ Supported | вќЊ Unsupported |
---|---|
6 (LTS) | 5 |
3.1 (LTS) | 3.0 |
2.2 | |
2.1 | |
2.0 | |
1.1 | |
1.0 |
For more information about the life cycle of .NET releases, see .NET and .NET Core Support Policy.
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:
Common dependencies
For .NET apps that use the System.Drawing.Common assembly, you’ll also need the following dependency:
You can install a recent version of libgdiplus by adding the Mono repository to your system. For more information, see https://www.mono-project.com/download/stable/.
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.
Bash is required to run the script.
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 SDK long term support (LTS) version, which is .NET 6. To install the current release, which may not be an (LTS) version, use the -c Current parameter.
To install .NET Runtime instead of the SDK, use the —runtime parameter.
You can install a specific version by altering the -c parameter to indicate the specific version. The following command installs .NET SDK 6.0.
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.
First, download a binary release for either the SDK or the runtime from one of the following sites. If you install the .NET SDK, you will not need to install the corresponding runtime:
Next, 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. This should make the .NET CLI commands available at the terminal.
Alternatively, after downloading the .NET binary, the following commands may be run from the directory where the file is saved to extract the runtime. This will also make the .NET CLI commands available at the terminal and set the required environment variables. Remember to change the DOTNET_FILE value to the name of the downloaded binary:
This approach lets you install different versions into separate locations and choose explicitly which one to use by which application.
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:
- Bash Shell:
/.bashrc
Korn Shell:
/.kshrc or .profile
Z Shell:
Set the following two environment variables in your shell profile:
This variable is set to the folder .NET was installed to, such as $HOME/.dotnet :
This variable should include both the DOTNET_ROOT folder and the user’s .dotnet/tools folder:
Christian Engvall
I write about software, app and web development.
Recent posts
Categories
Installing Visual Studio Code and ASP.NET Core on Linux Mint
In this post we’ll take a look at installing ASP.NET core and Visual Studio code on Linux Mint.
1. Installing .NET CORE
To install .NET Core I downloaded the X64 Binary and ran these commands in a console:
After that to verify the installation you can type dotnet :
2. Install Visual Studio Code
Go to https://code.visualstudio.com/ and select the .deb package for installation.
Click on Install Package — Visual studio Code debian package
After installing the package Visual Studio code will show up in the menu:
Visual studio code in the menu
3. Install the C# Extension
Click on the extensions icon to the left and search for C# . Then click install.
Visual studio csharp extension
4. Creating an ASP.NET Core Project
Now its time to create an ASP.NET MVC project from the terminal. These commands are copied from the Microsoft documentation
This creates a new mvc project in a folder called MvcMovie.
We can use the command line to open the newly created project in VS Code:
Установка .NET в Linux с помощью скрипта установки или извлечения двоичных файлов
В этой статье показано, как установить пакет SDK для .NET или среду выполнения .NET в Linux с помощью скрипта установки или извлечения двоичных файлов. Список дистрибутивов, поддерживающих встроенный диспетчер пакетов, см. в разделе Установка .NET в Linux.
Также можно установить .NET с помощью пакета Snap. Дополнительные сведения см. в разделе Установка пакета SDK для .NET или среды выполнения .NET с использованием пакета Snap.
Если вы хотите разрабатывать приложения .NET, установите пакет SDK (включает среду выполнения). Если нужно просто запустить приложения, установите среду выполнения. Если вы устанавливаете среду выполнения, мы рекомендуем установить среду выполнения ASP.NET Core, так как она включает в себя среды выполнения .NET и ASP.NET Core.
Если вы уже установили пакет SDK или среду выполнения, с помощью команд dotnet —list-sdks и dotnet —list-runtimes узнайте, какие версии установлены. Дополнительные сведения см. в статье Проверка того, установлена ли платформа .NET.
Выпуски .NET
В следующей таблице перечислены выпуски .NET (и .NET Core):
✔️ Поддерживается | ❌ Не поддерживается |
---|---|
6 (LTS) | 5 |
3.1 (LTS) | 3.0 |
2.2 | |
2.1 | |
2,0 | |
1,1 | |
1.0 |
Дополнительные сведения о жизненном цикле выпусков .NET см. в статье Политика поддержки .NET и .NET Core.
Зависимости
В некоторых случаях, например при установке .NET вручную, некоторые зависимости могут не устанавливаться. Ниже перечислены дистрибутивы Linux, которые поддерживаются корпорацией Майкрософт и для которых может потребоваться установка зависимостей. Дополнительные сведения см. на странице, посвященной соответствующему дистрибутиву:
Общие сведения о зависимостях см. в статье об автономных приложениях Linux.
Зависимости RPM
Если ваш дистрибутив не указан в приведенном выше списке и построен на основе RPM, могут потребоваться следующие зависимости:
Если в целевой среде выполнения установлена версия OpenSSL 1.1 или более поздняя, необходимо установить compat-openssl10.
Зависимости DEB
Если ваш дистрибутив не указан в приведенном выше списке и построен на основе Debian, могут потребоваться следующие зависимости:
Общие зависимости
Для приложений .NET, использующих сборку System.Drawing.Common, необходима также следующая зависимость:
Вы можете установить последнюю версию libgdiplus, добавив в систему репозиторий Mono. Для получения дополнительной информации см. https://www.mono-project.com/download/stable/.
Установка с помощью скрипта
Сценарии dotnet-install используются для автоматизации установок пакета SDK и среды выполнения и осуществления таких установок без прав администратора. Скрипт можно скачать на странице https://dot.net/v1/dotnet-install.sh.
Для выполнения скрипта требуется Bash.
Перед выполнением этого скрипта необходимо предоставить разрешение на выполнение этого скрипта в качестве исполняемого файла:
Этот скрипт по умолчанию устанавливает последнюю версию пакета SDK с долгосрочной поддержкой (LTS), которой сейчас является .NET 6. Чтобы установить текущий выпуск, который может не быть версией LTS, используйте параметр -c Current .
Чтобы вместо пакета SDK установить среду выполнения .NET, используйте параметр —runtime .
Вы можете установить определенную версию, указав ее в параметре -c . Следующая команда устанавливает пакет SDK для .NET 6.0.
Установка вручную
В качестве альтернативы диспетчерам пакетов можно скачать и вручную установить пакет SDK и среду выполнения. Установка вручную как правило выполняется в рамках тестирования непрерывной интеграции или в неподдерживаемом дистрибутиве Linux. В большинстве случаев разработчикам и пользователям рекомендуется использовать диспетчер пакетов.
Сначала скачайте двоичный выпуск пакета SDK или среды выполнения с одного из следующих сайтов. При установке пакета SDK для .NET не нужно устанавливать соответствующую среду выполнения:
Затем извлеките скачанный файл и используйте команду export , чтобы задать для переменной DOTNET_ROOT расположение извлеченной папки, а затем проверьте включение .NET в переменную PATH. После этого команды .NET CLI станут доступны в терминале.
Кроме того, после скачивания двоичного файла .NET можно выполнить следующие команды из каталога, в котором сохранен файл, для извлечения среды выполнения. После этого команды .NET CLI также станут доступны в терминале, и будут заданы нужные переменные среды. Обязательно измените значение DOTNET_FILE на имя скачанного двоичного файла:
Такой подход позволяет устанавливать разные версии в отдельные расположения и выбирать, какие из них следует использовать для каждого приложения.
Настройка системных переменных среды
Если вы использовали предыдущий скрипт установки, набор переменных применяется только к текущему сеансу терминала. Добавьте их в профиль оболочки. Существует несколько различных оболочек, доступных для Linux, и каждая из них имеет свой профиль. Пример:
- Оболочка Bash:
/.bashrc
Оболочка Korn:
/.kshrc или .profile
Оболочка Z:
Задайте следующие две переменные среды в профиле оболочки:
Эта переменная устанавливается в папку .NET, например $HOME/.dotnet :
Эта переменная должна содержать папку DOTNET_ROOT и папку dotnet/tools пользователя:
Name already in use
core / Documentation / linux-setup.md
- Go to file T
- Go to line L
- Copy path
- Copy permalink
Copy raw contents
Copy raw contents
Preparing your Linux system for .NET Core
There are a few options available for installing .NET Core on Linux systems and each requires a few actions before installing .NET Core. The sections below detail different methods for installing .NET Core and any prerequisites.
Other useful references
Installation using a package manager
Before installing .NET using a package manager, you will need to register the Microsoft key, register the product repository, and install required dependencies. This only needs to be done once per machine.
Open a command prompt and run the commands below that match your distro:
Ready to install
Your system is now ready to install .NET Core. See the Release Notes index for the latest available updates.
Installation from a binary archive
Installing from the packages detailed above is recommended or you can install from binary archive, if that better suits your needs. When using binary archives to install, the contents must be extracted to a user location such as $HOME/dotnet , a symbolic link created for dotnet and a few dependencies installed. Dependency requirements for each distro can be seen in the Linux System Prerequisites document.
Installation using Snap
We have been working on bringing .NET Core to Snap and are ready to hear what you think. Snaps, along with a few other technologies, are an emerging application installation and sandboxing technology which we think is pretty intriguing. The Snap install works well on Debian-based systems and other distros such as Fedora are having challenges that we’re working to run down. The following steps can be used if you would like to give this a try.
- Visit Snapcraft.io for guidance on preparing your system to use Snaps.
- As with our other installers, the Runtime and SDK are available depending on your needs. The SDK installation will include the .NET Core runtime and ASP.NET Core runtime.
SSL Certificate resolution with Snap installs
On some distros, a few environment variables need to be set in order for .NET Core to properly find the SSL certificate. You will know this is needed on your system if you get an error similar to the following during restore .
To resolve this issue
The certificate location will vary by distro. Here are the locations for the distros where we have experienced the issue.