Skip to content

Prefer the portable ILCompiler when publishing for the portable RID on a source-built SDK. #41754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public class ProcessFrameworkReferences : TaskBase
[Required]
public string NETCoreSdkRuntimeIdentifier { get; set; }

public string NETCoreSdkPortableRuntimeIdentifier { get; set; }

[Required]
public string NetCoreRoot { get; set; }

Expand Down Expand Up @@ -778,9 +780,17 @@ private ToolPackSupport AddToolPack(
var packNamePattern = knownPack.GetMetadata(packName + "PackNamePattern");
var packSupportedRuntimeIdentifiers = knownPack.GetMetadata(packName + "RuntimeIdentifiers").Split(';');

// When publishing for the non-portable RID that matches NETCoreSdkRuntimeIdentifier, prefer NETCoreSdkRuntimeIdentifier for the host.
// Otherwise prefer the NETCoreSdkPortableRuntimeIdentifier.
// This makes non-portable SDKs behave the same as portable SDKs except for the specific case of targetting the non-portable RID.
// It also enables the non-portable ILCompiler to be packaged separately from the SDK and
// only required when publishing for the non-portable SDK RID.
string portableSdkRid = !string.IsNullOrEmpty(NETCoreSdkPortableRuntimeIdentifier) ? NETCoreSdkPortableRuntimeIdentifier : NETCoreSdkRuntimeIdentifier;
bool targetsNonPortableSdkRid = RuntimeIdentifier == NETCoreSdkRuntimeIdentifier && NETCoreSdkRuntimeIdentifier != portableSdkRid;
string hostRuntimeIdentifier = targetsNonPortableSdkRid ? NETCoreSdkRuntimeIdentifier : portableSdkRid;
// Get the best RID for the host machine, which will be used to validate that we can run crossgen for the target platform and architecture
var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
var hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, NETCoreSdkRuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph);
hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, hostRuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph);
if (hostRuntimeIdentifier == null)
{
return ToolPackSupport.UnsupportedForHostRuntimeIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Copyright (c) .NET Foundation. All rights reserved.
KnownWebAssemblySdkPacks="@(KnownWebAssemblySdkPack)"
UsingMicrosoftNETSdkWebAssembly="$(UsingMicrosoftNETSdkWebAssembly)"
NETCoreSdkRuntimeIdentifier="$(NETCoreSdkRuntimeIdentifier)"
NETCoreSdkPortableRuntimeIdentifier="$(NETCoreSdkPortableRuntimeIdentifier)"
NetCoreRoot="$(NetCoreRoot)"
NETCoreSdkVersion="$(NETCoreSdkVersion)">

Expand Down