Table of Contents
RID - Runtime Identifier for C# .NET
- Runtime Identifier for C Sharp Dot Net
01/28/2021 4 minutes to read
+15 RID is short for Runtime Identifier. RID values are used to identify target platforms where the application runs. They're used by .NET packages to represent platform-specific assets in NuGet packages. The following values are examples of RIDs: linux-x64, ubuntu.14.04-x64, win7-x64, or osx.10.12-x64. For the packages with native dependencies, the RID designates on which platforms the package can be restored.
A single RID can be set in the <RuntimeIdentifier> element of your project file. Multiple RIDs can be defined as a semicolon-delimited list in the project file's <RuntimeIdentifiers> element. They're also used via the –runtime option with the following .NET CLI commands:
dotnet build dotnet clean dotnet pack dotnet publish dotnet restore dotnet run dotnet store RIDs that represent concrete operating systems usually follow this pattern: [os].[version]-[architecture]-[additional qualifiers] where:
[os] is the operating/platform system moniker. For example, ubuntu.
[version] is the operating system version in the form of a dot-separated (.) version number. For example, 15.10.
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] is the processor architecture. For example: x86, x64, arm, or arm64.
[additional qualifiers] further differentiate different platforms. For example: aot.
RID graph The RID graph or runtime fallback graph is a list of RIDs that are compatible with each other. The RIDs are defined in the Microsoft.NETCore.Platforms package. You can see the list of supported RIDs and the RID graph in the runtime.json file, which is located in the dotnet/runtime repository. In this file, you can see that all RIDs, except for the base one, contain an “
- import” statement. These statements indicate compatible RIDs.
When NuGet restores packages, it tries to find an exact match for the specified runtime. If an exact match is not found, NuGet walks back the graph until it finds the closest compatible system according to the RID graph.
The following example is the actual entry for the osx.10.12-x64 RID:
JSON
Copy “osx.10.12-x64”: {
"#import": [ "osx.10.12", "osx.10.11-x64" ]} The above RID specifies that osx.10.12-x64 imports osx.10.11-x64. So, when NuGet restores packages, it tries to find an exact match for osx.10.12-x64 in the package. If NuGet cannot find the specific runtime, it can restore packages that specify osx.10.11-x64 runtimes, for example.
The following example shows a slightly bigger RID graph also defined in the runtime.json file:
Copy
win7-x64 win7-x86 | \ / | | win7 | | | | win-x64 | win-x86 \ | / win | anyAll RIDs eventually map back to the root any RID.
There are some considerations about RIDs that you have to keep in mind when working with them:
Don't try to parse RIDs to retrieve component parts. Don't build RIDs programmatically. Use RIDs that are already defined for the platform. The RIDs need to be specific, so don't assume anything from the actual RID value. Using RIDs To be able to use RIDs, you have to know which RIDs exist. New values are added regularly to the platform. For the latest and complete version, see the runtime.json file in the dotnet/runtime repository.
Portable RIDs are values added to the RID graph that aren't tied to a specific version or OS distribution. They are the preferred choice, especially when dealing with multiple Linux distros since most distribution RIDs are mapped to the portable RIDs.
The following list shows a small subset of the most common RIDs used for each OS.
Windows RIDs
Only common values are listed. For the latest and complete version, see the runtime.json file in the dotnet/runtime repository.
Portable win-x64 win-x86 win-arm win-arm64 Windows 7 / Windows Server 2008 R2 win7-x64 win7-x86 Windows 8.1 / Windows Server 2012 R2 win81-x64 win81-x86 win81-arm Windows 10 / Windows Server 2016 win10-x64 win10-x86 win10-arm win10-arm64