Skip to content

Commit 5879f1b

Browse files
authored
Use PortableRuntimeIdentifierGraph in ToolPackage
1 parent dec5a57 commit 5879f1b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/Cli/dotnet/ToolPackage/ToolPackageDownloaderBase.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ protected ToolPackageDownloaderBase(
5757
_currentWorkingDirectory = currentWorkingDirectory;
5858

5959
_localToolAssetDir = new DirectoryPath(_fileSystem.Directory.CreateTemporarySubdirectory());
60-
_runtimeJsonPath = runtimeJsonPathForTests ?? Path.Combine(AppContext.BaseDirectory!, "RuntimeIdentifierGraph.json");
60+
61+
// Tools target modern (net8.0+) frameworks, for which the SDK resolves RIDs using the simplified
62+
// "portable" RID graph by default (UseRidGraph=false). Prefer that graph here so tool RID-asset
63+
// selection matches normal restore/build; fall back to the legacy graph if the portable one isn't
64+
// present in the layout.
65+
string portableRuntimeJsonPath = Path.Combine(AppContext.BaseDirectory!, "PortableRuntimeIdentifierGraph.json");
66+
string legacyRuntimeJsonPath = Path.Combine(AppContext.BaseDirectory!, "RuntimeIdentifierGraph.json");
67+
_runtimeJsonPath = runtimeJsonPathForTests
68+
?? (File.Exists(portableRuntimeJsonPath) ? portableRuntimeJsonPath : legacyRuntimeJsonPath);
6169
}
6270

6371
protected abstract INuGetPackageDownloader CreateNuGetPackageDownloader(

0 commit comments

Comments
 (0)