Skip to content

[Breaking change]: RuntimeInformation.RuntimeIdentifier returns platform for which the runtime was built #36466

Closed
@elinor-fung

Description

@elinor-fung

Description

RuntimeInformation.RuntimeIdentifier will return the platform for which the runtime was built, rather than a value computed at run time.

PR: dotnet/runtime#89598
Related:

Version

.NET 8 RC 1

Previous behavior

The value was a RID computed via OS files and/or APIs. This generally meant it was a version-specific and distro-specific RID. For example, when running an application on Windows 11, it would be win10-x64 or on Ubuntu 20.04, it could be ubuntu.20.04-x64.

New behavior

The value is the RID for which the runtime was built. This means that for portable builds of the runtime (all Microsoft-provided builds), it will be non-version-specific and non-distro-specific. For example, when on Windows 11, it would be win-x64 or on Ubuntu 20.04, linux-x64. For non-portable builds (source-build), the build sets a build RID at that can have a version/distro and that value is the RID for the runtime will return.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

This is in line with a .NET 8 change to RID-specific asset resolution and the move away from a distro-aware runtime. RuntimeInformation.RuntimeIdentifier is an opaque value that should represent the platform on which the host/runtime considers itself to be running. In .NET 8, that corresponds to the platform for which the host/runtime is built, rather than a RID computed at run time.

Recommended action

RuntimeInformation.RuntimeIdentifier is an opaque value and not intended to be parsed into its component parts. For the OS version of the actual machine an application is running on, Environment.OSVersion can be used. For a description, RuntimeInformation.OSDescription can be used. For a specific ID (distro) and corresponding version on Linux, users would have to read the os-release file.

Feature area

Core .NET libraries

Affected APIs

RuntimeInformation.RuntimeIdentifier


Associated WorkItem - 156743

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions