Linux 上 .NET Core 的先决条件Prerequisites for .NET Core on Linux

本文介绍了在 Linux 上开发 .NET Core 应用程序所需的依赖项。This article shows the dependencies needed to develop .NET Core applications on Linux. 支持的 Linux 发行版本/版本和依赖项适用于在 Linux 上开发 .NET Core 应用程序的两种方法:The supported Linux distributions/versions, and dependencies that follow apply to the two ways of developing .NET Core apps on Linux:


生产服务器/环境不需要 .NET Core SDK 包。The .NET Core SDK package is not required for production servers/environments. 部署到生产环境的应用只需要 .NET Core 运行时包。Only the .NET Core runtime package is needed for apps deployed to production environments. .NET Core 运行时与应用一同部署为独立部署的一部分,但是,对于依赖框架的部署应用,它必须单独部署。The .NET Core runtime is deployed with apps as part of a self-contained deployment, however, it must be deployed for Framework-dependent deployed apps separately. 有关依赖框架和独立部署类型的更多信息,请参阅 .NET Core 应用程序部署For more information about framework-dependent and self-contained deployment types, see .NET Core application deployment. 另请参阅独立式 Linux 应用程序,了解特定准则。Also see Self-contained Linux applications for specific guidelines.

支持的 Linux 版本Supported Linux versions

.NET Core 2.x 将 Linux 视为一个操作系统。.NET Core 2.x treats Linux as a single operating system. 支持的 Linux 分发都对应有一个 Linux 内部版本(根据芯片体系结构)。There is a single Linux build (per chip architecture) for supported Linux distributions.

有关下载链接和详细信息,请参阅 .NET Core 2.2 下载.NET Core 2.1 下载For download links and more information, see .NET Core 2.2 downloads or .NET Core 2.1 downloads.

以下 Linux 发行版本/版本支持 .NET Core 2.x:.NET Core 2.x is supported on the following Linux distributions/versions:

  • Red Hat Enterprise Linux 7,6 - 64 位(x86_64amd64Red Hat Enterprise Linux 7, 6 - 64-bit (x86_64 or amd64)
  • CentOS 7 - 64 位(x86_64amd64CentOS 7 - 64-bit (x86_64 or amd64)
  • Oracle Linux 7 - 64 位(x86_64amd64Oracle Linux 7 - 64-bit (x86_64 or amd64)
  • Fedora 28、27 - 64 位(x86_64amd64Fedora 28, 27 - 64-bit (x86_64 or amd64)
  • Debian 9(64 位,arm32)、8.7 或更高版本 - 64 位(x86_64amd64Debian 9 (64-bit, arm32), 8.7 or later versions - 64-bit (x86_64 or amd64)
  • Ubuntu 18.04(64 位,arm32)、16.04、14.04 - 64 位(x86_64amd64Ubuntu 18.04 (64-bit, arm32), 16.04, 14.04 - 64-bit (x86_64 or amd64)
  • Linux Mint 18、17 - 64 位(x86_64amd64Linux Mint 18, 17 - 64-bit (x86_64 or amd64)
  • openSUSE 42.3 或更高版本 - 64 位(x86_64amd64openSUSE 42.3 or later versions - 64-bit (x86_64 or amd64)
  • SUSE Enterprise Linux (SLES) 12 Service Pack 2 或更高版本 - 64 位(x86_64amd64SUSE Enterprise Linux (SLES) 12 Service Pack 2 or later - 64-bit (x86_64 or amd64)
  • Alpine Linux 3.7 或更高版本 - 64 位(x86_64amd64Alpine Linux 3.7 or later versions - 64-bit (x86_64 or amd64)

有关 .NET Core 2.1 和 .NET Core 2.2 支持的操作系统、发行版本和版本、不支持的 OS 版本和生命周期策略链接的完整列表,请参阅 .NET Core 2.1 支持的 OS 版本.NET Core 2.2 支持的 OS 版本See .NET Core 2.1 Supported OS Versions and .NET Core 2.2 Supported OS Versions for the complete list of .NET Core 2.1 and .NET Core 2.2 supported operating systems, distributions and versions, out of support OS versions, and lifecycle policy links.

Linux 发行版本依赖项Linux distribution dependencies

以下各项用作示例。The following are intended to be examples. 确切的版本和名称可能因所选 Linux 发行版本略有不同。The exact versions and names may vary slightly on your Linux distribution of choice.


Ubuntu 发行版本需要安装以下库:Ubuntu distributions require the following libraries installed:

  • liblttng-ust0liblttng-ust0
  • libcurl3(针对 14.x 和 16.x)libcurl3 (for 14.x and 16.x)
  • libcurl4(针对 18.x)libcurl4 (for 18.x)
  • libssl1.0.0libssl1.0.0
  • libkrb5-3libkrb5-3
  • zlib1gzlib1g
  • libicu52(针对 14.x)libicu52 (for 14.x)
  • libicu55(针对 16.x)libicu55 (for 16.x)
  • libicu57(针对 17.x)libicu57 (for 17.x)
  • libicu60(针对 18.x)libicu60 (for 18.x)

对于 .NET Core 2.1 之前的版本,还需要以下依赖项:For versions earlier than .NET Core 2.1, following dependencies are also required:

  • libunwind8libunwind8
  • libuuid1libuuid1

CentOS 和 FedoraCentOS and Fedora

CentOS 发行版本需要安装以下库:CentOS distributions require the following libraries installed:

  • lttng-ustlttng-ust
  • libcurllibcurl
  • openssl-libsopenssl-libs
  • krb5-libskrb5-libs
  • libiculibicu
  • zlibzlib

Fedora 用户:如果 openssl 的版本为 1.1 及以上版本,则需要安装 compat-openssl10。Fedora users: If your openssl's version >= 1.1, you'll need to install compat-openssl10.

对于 .NET Core 2.1 之前的版本,还需要以下依赖项:For versions earlier than .NET Core 2.1, following dependencies are also required:

  • libunwindlibunwind
  • libuuidlibuuid

有关依赖项的详细信息,请参阅独立式 Linux 应用程序For more information about the dependencies, see Self-contained Linux applications.

使用本机安装程序安装 .NET Core 依赖项Installing .NET Core dependencies with the native installers

.NET Core 本机安装程序适用于支持的 Linux 发行版本/版本。.NET Core native installers are available for supported Linux distributions/versions. 本机安装程序需要拥有对服务器的管理员 (sudo) 访问权限。The native installers require admin (sudo) access to the server. 使用本机安装程序的优势在于,可以安装所有 .NET Core 本机依赖项。The advantage of using a native installer is that all of the .NET Core native dependencies are installed. 本机安装程序还会在整个系统内安装 .NET Core SDK。Native installers also install the .NET Core SDK system-wide.

在 Linux 上,安装程序包有两种使用方式:On Linux, there are two installer package choices:

  • 使用基于源的包管理器,如适用于 Ubuntu 的 apt-get,或适用于 CentOS/RHEL 的 yum。Using a feed-based package manager, such as apt-get for Ubuntu, or yum for CentOS/RHEL.
  • 使用包本身(DEB 或 RPM)。Using the packages themselves, DEB or RPM.

使用 .NET Core 安装程序脚本编写安装脚本Scripting Installs with the .NET Core installer script

dotnet-install 脚本用于执行 CLI 工具链和共享运行时的非管理员安装。The dotnet-install scripts are used to perform a non-admin install of the CLI toolchain and the shared runtime. 可通过 下载脚本。You can download the script from

此脚本会默认安装最新的“LTS”版本,当前为 .NET Core 1.1。The script defaults to installing the latest "LTS" version, which is currently .NET Core 1.1. 要安装 .NET Core 2.1,请使用以下开关运行脚本:To install .NET Core 2.1, run the script with the following switch:

./ -c Current

安装程序 bash 脚本用于自动化方案和非管理员安装。The installer bash script is used in automation scenarios and non-admin installations. 此脚本也读取 PowerShell 开关,因此可以与 Linux/OS X 系统上的脚本结合使用。This script also reads PowerShell switches, so they can be used with the script on Linux/OS X systems.


若对在支持的 Linux 分发/版本上安装 .NET Core 有疑问,请参阅下方你所安装的分发/版本的相应主题:If you have problems with a .NET Core installation on a supported Linux distribution/version, consult the following topics for your installed distributions/versions: