.NET Core RID 類別目錄.NET Core RID Catalog

RID 是執行階段識別項的縮寫。RID is short for Runtime IDentifier. RID 值是用來識別應用程式執行所在的目標平台。RID values are used to identify target platforms where the application runs. .NET 套件會使用它們來代表 NuGet 套件中的平台特定資產。They're used by .NET packages to represent platform-specific assets in NuGet packages. 下列值是 RID 的範例:linux-x64ubuntu.14.04-x64win7-x64osx.10.12-x64The following values are examples of RIDs: linux-x64, ubuntu.14.04-x64, win7-x64, or osx.10.12-x64. 針對具有原生相依性的套件,RID 也可指定能在哪些平台上還原套件。For the packages with native dependencies, the RID designates on which platforms the package can be restored.

單一 RID 可在您專案檔的 <RuntimeIdentifier> 元素中設定。A single RID can be set in the <RuntimeIdentifier> element of your project file. 可以在專案檔的 <RuntimeIdentifiers> 元素中,將多個 RID 定義為以分號分隔的清單。Multiple RIDs can be defined as a semicolon-delimited list in the project file's <RuntimeIdentifiers> element. 它們也可以透過以--runtime選項搭配下列 .NET Core CLI 命令來使用:They're also used via the --runtime option with the following .NET Core CLI commands:

代表具體作業系統的 RID 通常遵循 [os].[version]-[architecture]-[additional qualifiers] 這個模式,其中:RIDs that represent concrete operating systems usually follow this pattern: [os].[version]-[architecture]-[additional qualifiers] where:

  • [os] 是作業/平台系統 Moniker。[os] is the operating/platform system moniker. 例如,ubuntuFor example, ubuntu.

  • [version] 是作業系統版本,使用以點分隔 (.) 的版本號碼表示。[version] is the operating system version in the form of a dot-separated (.) version number. 例如,15.10For example, 15.10.

    • 版本不應為行銷版本,因為行銷版本通常代表作業系統的多個個別版本,且具有不同平台 API 介面區。The version shouldn't be marketing versions, as they often represent multiple discrete versions of the operating system with varying platform API surface area.
  • [architecture] 處理器架構。[architecture] is the processor architecture. 例如:x86x64armarm64For example: x86, x64, arm, or arm64.

  • [additional qualifiers] 進一步區分不同平台。[additional qualifiers] further differentiate different platforms. 例如:aotFor example: aot.

RID 圖表RID graph

RID 圖表或執行階段後援圖形是與彼此相容的 RID 清單。The RID graph or runtime fallback graph is a list of RIDs that are compatible with each other. RID 是在 Microsoft.NETCore.Platforms 套件中定義。The RIDs are defined in the Microsoft.NETCore.Platforms package. 您可以在 runtime.json 檔案 (位於 CoreFX 存放庫) 中看到支援的 RID 清單與 RID 圖形。You can see the list of supported RIDs and the RID graph in the runtime.json file, which is located at the CoreFX repo. 在此檔案中,您可以看到所有 RID (基底項目除外) 都包含 "#import" 陳述式。In this file, you can see that all RIDs, except for the base one, contain an "#import" statement. 這些陳述式指出相容的 RID。These statements indicate compatible RIDs.

當 NuGet 還原套件時,它會嘗試尋找與所指定執行階段完全相符的項目。When NuGet restores packages, it tries to find an exact match for the specified runtime. 若找不到完全相符的項目,NuGet 會返回到圖形,直到它根據 RID 圖形找到最接近的相容系統。If an exact match is not found, NuGet walks back the graph until it finds the closest compatible system according to the RID graph.

下列範例是 osx.10.12-x64 RID 的實際項目:The following example is the actual entry for the osx.10.12-x64 RID:

"osx.10.12-x64": {
    "#import": [ "osx.10.12", "osx.10.11-x64" ]
}

上述 RID 指定 osx.10.12-x64 匯入 osx.10.11-x64The above RID specifies that osx.10.12-x64 imports osx.10.11-x64. 因此,當 NuGet 還原套件時,它會嘗試在套件中尋找與 osx.10.12-x64 完全相符的項目。So, when NuGet restores packages, it tries to find an exact match for osx.10.12-x64 in the package. 例如,若 NuGet 找不到特定執行階段,它可以還原指定 osx.10.11-x64 執行階段的套件。If NuGet cannot find the specific runtime, it can restore packages that specify osx.10.11-x64 runtimes, for example.

下列範例顯示也在 runtime.json 檔案中定義的稍大 RID 圖形:The following example shows a slightly bigger RID graph also defined in the runtime.json file:

    win7-x64    win7-x86
       |   \   /    |
       |   win7     |
       |     |      |
    win-x64  |  win-x86
          \  |  /
            win
             |
            any

所有的 RID 最終將對應至根 any RID。All RIDs eventually map back to the root any RID.

處理 RID 時,您必須謹記一些考量:There are some considerations about RIDs that you have to keep in mind when working with them:

  • RID 是隱晦字串,因此必須以黑箱視之。RIDs are opaque strings and should be treated as black boxes.
  • 不要以程式設計方式建置 RID。Don't build RIDs programmatically.
  • 使用已針對平台定義的 RID。Use RIDs that are already defined for the platform.
  • RID 必須是特定的,因此不要假設實際 RID 值會怎樣。The RIDs need to be specific, so don't assume anything from the actual RID value.

使用 RIDUsing RIDs

若要使用 RID,必須先了解有哪些 RID 存在。To be able to use RIDs, you have to know which RIDs exist. 新的值會定期新增至平台。New values are added regularly to the platform. 如需最新的完整版本,請查看 CoreFX 存放庫上的 runtime.json 檔案。For the latest and complete version, see the runtime.json file on CoreFX repo.

.NET Core 2.0 SDK 引進可攜式 RID 的概念。.NET Core 2.0 SDK introduces the concept of portable RIDs. 它們是新增到 RID 圖形且未繫結到特定版本或 OS 發行版本的新值,適用於 .NET Core 2.0 和更新版本。They are new values added to the RID graph that aren't tied to a specific version or OS distribution and are the preferred choice when using .NET Core 2.0 and higher. 由於大部分發行版本的 RID 都會對應至可攜式 RID,因此在處理多個 Linux 發行版本時特別有用。They're particularly useful when dealing with multiple Linux distros since most distribution RIDs are mapped to the portable RIDs.

下列清單顯示用於每個 OS 的一小部分最常見 RID。The following list shows a small subset of the most common RIDs used for each OS.

Windows RIDWindows RIDs

僅列出常見值。Only common values are listed. 如需最新的完整版本,請查看 CoreFX 存放庫上的 runtime.json 檔案。For the latest and complete version, see the runtime.json file on CoreFX repo.

  • 可攜式 (.NET Core 2.0 或更新版本)Portable (.NET Core 2.0 or later versions)
    • win-x64
    • win-x86
    • win-arm
    • win-arm64
  • Windows 7/Windows Server 2008 R2Windows 7 / Windows Server 2008 R2
    • win7-x64
    • win7-x86
  • Windows 8.1/Windows Server 2012 R2Windows 8.1 / Windows Server 2012 R2
    • win81-x64
    • win81-x86
    • win81-arm
  • Windows 10/Windows Server 2016Windows 10 / Windows Server 2016
    • win10-x64
    • win10-x86
    • win10-arm
    • win10-arm64

如需詳細資訊,請參閱 Windows 上 .NET Core 的必要條件See Prerequisites for .NET Core on Windows for more information.

Linux RIDLinux RIDs

僅列出常見值。Only common values are listed. 如需最新的完整版本,請查看 CoreFX 存放庫上的 runtime.json 檔案。For the latest and complete version, see the runtime.json file on CoreFX repo. 如果下方未列出裝置執行的發行版本,裝置可能可以使用其中一個可攜式 RID。Devices running a distribution not listed below may work with one of the Portable RIDs. 例如,如果 Raspberry Pi 裝置執行未列出的 Linux 發行版本,則可以 linux-arm 為目標。For example, Raspberry Pi devices running a Linux distribution not listed can be targeted with linux-arm.

  • 可攜式 (.NET Core 2.0 或更新版本)Portable (.NET Core 2.0 or later versions)
    • linux-x64 (大部分的桌面發行版本,如 CentOS、Debian、Fedora、Ubuntu 和衍生版)linux-x64 (Most desktop distributions like CentOS, Debian, Fedora, Ubuntu and derivatives)
    • linux-musl-x64 (使用 musl 的輕量發行版本,如 Alpine Linux)linux-musl-x64 (Lightweight distributions using musl like Alpine Linux)
    • linux-arm (在 ARM 上執行的 Linux 發行版本,如 Raspberry Pi)linux-arm (Linux distributions running on ARM like Raspberry Pi)
  • Red Hat Enterprise LinuxRed Hat Enterprise Linux
    • rhel-x64 (RHEL 6 版以上已由 linux-x64 取代)rhel-x64 (Superseded by linux-x64 for RHEL above version 6)
    • rhel.6-x64 (.NET Core 2.0 或更新版本)rhel.6-x64 (.NET Core 2.0 or later versions)
  • Tizen (.NET Core 2.0 或更新版本)Tizen (.NET Core 2.0 or later versions)
    • tizen
    • tizen.4.0.0
    • tizen.5.0.0

如需詳細資訊,請參閱 Linux 上 .NET Core 的必要條件See Prerequisites for .NET Core on Linux for more information.

macOS RIDmacOS RIDs

macOS RID 使用較舊的 "OSX" 商標。macOS RIDs use the older "OSX" branding. 僅列出常見值。Only common values are listed. 如需最新的完整版本,請查看 CoreFX 存放庫上的 runtime.json 檔案。For the latest and complete version, see the runtime.json file on CoreFX repo.

  • 可攜式 (.NET Core 2.0 或更新版本)Portable (.NET Core 2.0 or later versions)
    • osx-x64 (最低 OS 版本為 macOS 10.12 Sierra)osx-x64 (Minimum OS version is macOS 10.12 Sierra)
  • macOS 10.10 YosemitemacOS 10.10 Yosemite
    • osx.10.10-x64
  • macOS 10.11 El CapitanmacOS 10.11 El Capitan
    • osx.10.11-x64
  • macOS 10.12 Sierra (.NET Core 1.1 或更新版本)macOS 10.12 Sierra (.NET Core 1.1 or later versions)
    • osx.10.12-x64
  • macOS 10.13 High Sierra (.NET Core 1.1 或更新版本)macOS 10.13 High Sierra (.NET Core 1.1 or later versions)
    • osx.10.13-x64
  • macOS 10.14 Mojave (.NET Core 1.1 或更新版本)macOS 10.14 Mojave (.NET Core 1.1 or later versions)
    • osx.10.14-x64

如需詳細資訊,請參閱 macOS 上 .NET Core 的必要條件See Prerequisites for .NET Core on macOS for more information.

另請參閱See also