Skip to content

.NET Standard RuntimeInformation doesn't have RuntimeIdentifier property #118555

@MV10

Description

@MV10

Description

I am updating a NET Standard 2.0 library to .NET 8 packages due to vulnerabilities in .NET Core 2.1 dependencies.

The project involves cross-platform library loading, and under .NET Core 2.1 it relied upon GetRuntimeIdentifier() to determine the RID. There was a breaking change to RID usage in .NET 8. Since I'm not currently equipped to test cross-platform functionality, I wanted to use the <UseRidGraph> workaround to revert to the old functionality.

However, the API also changed and now I must read the RuntimeInformation.RuntimeIdentifier property (same page as the "workaround" link above) instead of calling GetRundtimeIdentifier().

Unfortunately that property doesn't appear to be provided even though the docs say it is part of netstandard.dll:

Image

Reproduction Steps

Create a .NET Standard 2.0 class library.

Modify the csproj to add UseRidGraph:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <RootNamespace>Issue_RuntimeIdentifier</RootNamespace>
  </PropertyGroup>

  <PropertyGroup>
    <UseRidGraph>true</UseRidGraph>
  </PropertyGroup>
	
</Project>

Reference the property in code:

using System.Runtime.InteropServices;
namespace Issue_RuntimeIdentifier
{
    public class Class1
    {
        public string GetRID() 
            => RuntimeInformation.RuntimeIdentifier;
                               // ^^ CS0117: 'RuntimeInformation' does not contain a definition for 'RuntimeIdentifier'
    }
}

Expected behavior

RuntimeIdentifier property should exist.

Actual behavior

CS0117: 'RuntimeInformation' does not contain a definition for 'RuntimeIdentifier'

Regression?

Unknown if this is a regression.

Known Workarounds

No known workaround.

Configuration

.NET 8 (whatever is current) ... don't think other details are likely relevant.

Other information

I don't think it'll help much, but you can see the code in context here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions