Skip to content

Commit

Permalink
Look up the target OS for crossgen2 using the full target RID (#45566)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky authored Dec 30, 2024
1 parent e8a3400 commit 6062d02
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,42 +181,19 @@ private bool GetCrossgen2TargetOS(out string targetOS)

// Determine targetOS based on target rid.
// Use the runtime graph to support non-portable target rids.
// Use the full target rid instead of just the target OS as the runtime graph
// may only have the full target rid and not an OS-only rid for non-portable target rids
// added by our source-build partners.
var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
string portablePlatform = NuGetUtils.GetBestMatchingRid(
runtimeGraph,
_targetPlatform,
new[] { "linux", "linux-musl", "osx", "win", "freebsd", "illumos" },
_targetRuntimeIdentifier,
new[] { "linux", "osx", "win", "freebsd", "illumos" },
out _);

// For source-build, allow the bootstrap SDK rid to be unknown to the runtime repo graph.
if (portablePlatform == null && _targetRuntimeIdentifier == _hostRuntimeIdentifier)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
portablePlatform = "win";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
portablePlatform = "linux";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")))
{
portablePlatform = "freebsd";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ILLUMOS")))
{
portablePlatform = "illumos";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
portablePlatform = "osx";
}
}

targetOS = portablePlatform switch
{
"linux" => "linux",
"linux-musl" => "linux",
"osx" => "osx",
"win" => "windows",
"freebsd" => "freebsd",
Expand Down

0 comments on commit 6062d02

Please sign in to comment.