Skip to content

Use PortableRuntimeIdentifierGraph in ToolPackage#55046

Open
am11 wants to merge 2 commits into
dotnet:mainfrom
am11:patch-7
Open

Use PortableRuntimeIdentifierGraph in ToolPackage#55046
am11 wants to merge 2 commits into
dotnet:mainfrom
am11:patch-7

Conversation

@am11

@am11 am11 commented Jun 27, 2026

Copy link
Copy Markdown
Member

The legacy graph is frozen since .NET 8 and we are supposed to use portable graph for new platforms. However, after building OpenBSD, I found that "dotnet tool" fails as it ends up using the legacy graph.

@jkotas

jkotas commented Jun 27, 2026

Copy link
Copy Markdown
Member

I found that "dotnet tool" fails as it ends up using the legacy graph.

Where does it end up using it?

@am11

am11 commented Jun 27, 2026

Copy link
Copy Markdown
Member Author

<Copy SourceFiles="$(NuGetPackageRoot)/microsoft.netcore.platforms/$(MicrosoftNETCorePlatformsPackageVersion)/runtime.json"
DestinationFiles="$(OutputPath)RuntimeIdentifierGraph.json"
SkipUnchangedFiles="true" />

It copies runtime.json (legacy graph) as RuntimeIdentifier.json which ends up at .dotnet/sdk/11.0.100-preview.7.26327.199/RuntimeIdentifierGraph.json (next to .dotnet/sdk/11.0.100-preview.7.26327.199/PortableRuntimeIdentifierGraph.json). At that point, it has self-referencing entry:

    "openbsd-x64": {
      "#import": [
        "openbsd-x64"
      ]
    }

(without the proper hierarchy)

It's added by https://github.com/dotnet/runtime/blob/8207ad3ca9ad1f77606f27150c3c26ca47812f86/src/libraries/Microsoft.NETCore.Platforms/src/UpdateRuntimeIdentifierGraph.cs#L44.

@am11

am11 commented Jun 27, 2026

Copy link
Copy Markdown
Member Author

I published openbsd-x64 sdk via GA workflow https://github.com/am11/dotnet-riscv/releases/tag/11.0.100-preview.7.26327.199, if you extract the tar, you will find both files under that location.

@jkotas

jkotas commented Jun 28, 2026

Copy link
Copy Markdown
Member

self-referencing entry

That sounds like a bug at https://github.com/dotnet/runtime/blob/567a079a3f45e2e217815b49e1e09fa76ab72f11/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj#L29C46-L29C55 . This line will introduce the self-reference when TargetRid == PortableTargetRid .

@am11

am11 commented Jun 28, 2026

Copy link
Copy Markdown
Member Author

@jkotas, I have tested with this PR and can confirm that dotnet tool install/restore works which was failing before. I think we wanted to move on from legacy RID graph, so it makes sense to use PortableRuntimeIdentifierGraph (unlikely that people are using non-portable RID for tools, because it builds the shim using the executing SDK regardless of its portability).

If it makes sense then this PR switching to portable graph (when available; not available in <.NET8 TFMs) can move forward.

dotnet/runtime#129929 is optional; it only makes sense if this PR is not accepted, or if we want to support <UseRidGraph>true (https://github.com/dotnet/docs/blob/51e9afa6123259b9e505e2bc80d53865336b5ab6/docs/core/tools/sdk-errors/netsdk1206.md) for newly on-boarded platforms (which I doubt is interesting at all for openbsd).

That sounds like a bug at dotnet/runtime@567a079/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj#L29C46-L29C55 . This line will introduce the self-reference when TargetRid == PortableTargetRid .

Correctness fix is in dotnet/runtime#129944 (i.e. it is unrelated to dotnet tool restore fix).

Comment thread src/Cli/dotnet/ToolPackage/ToolPackageDownloaderBase.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates dotnet tool’s RID graph lookup to use the portable runtime identifier graph so newer platforms (e.g., OpenBSD) can resolve RID-specific tool packages correctly, aligning tool behavior with post-.NET 8 RID-graph expectations.

Changes:

  • Switch default runtime graph file from RuntimeIdentifierGraph.json (legacy/frozen) to PortableRuntimeIdentifierGraph.json for tool package operations.

Comment thread src/Cli/dotnet/ToolPackage/ToolPackageDownloaderBase.cs

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrating away from the legacy RID graph for tools looks good to me.

I will leave this for the tools area owners to sign off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants