Skip to content
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
22 changes: 14 additions & 8 deletions src/sdk/src/Layout/redist/targets/GenerateBundledVersions.targets
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,6 @@
Condition="'$(BundleRuntimePacks)' == 'true'"
Include="$(ProductMonikerRid)" />

<ILCompilerSupportedRids
Condition="'$(BundleNativeAotCompiler)' == 'true'"
Include="$(ProductMonikerRid)" />

<Crossgen2SupportedRids
Condition="'$(BundleCrossgen2)' == 'true'"
Include="$(ProductMonikerRid)" />

<Net60MonoRuntimePackRids Include="
@(Net60RuntimePackRids);
browser-wasm;
Expand Down Expand Up @@ -368,6 +360,12 @@

<Crossgen2SupportedRids Include="@(Net90Crossgen2SupportedRids);" />

<Crossgen2SupportedPortableRids Include="@(Crossgen2SupportedRids)" />

<Crossgen2SupportedRids
Condition="'$(BundleCrossgen2)' == 'true'"
Include="$(ProductMonikerRid)" />

<Net70ILCompilerSupportedRids Include="
linux-arm64;
linux-musl-arm64;
Expand Down Expand Up @@ -402,6 +400,12 @@
linux-musl-riscv64;
" />

<ILCompilerSupportedPortableRids Include="@(ILCompilerSupportedRids)" />

<ILCompilerSupportedRids
Condition="'$(BundleNativeAotCompiler)' == 'true'"
Include="$(ProductMonikerRid)" />

<Net80NativeAOTRuntimePackRids Include="
ios-arm64;
iossimulator-arm64;
Expand Down Expand Up @@ -580,6 +584,7 @@ Copyright (c) .NET Foundation. All rights reserved.
TargetFramework="net10.0"
Crossgen2PackNamePattern="Microsoft.NETCore.App.Crossgen2.**RID**"
Crossgen2PackVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)"
Crossgen2PortableRuntimeIdentifiers="@(Crossgen2SupportedPortableRids, '%3B')"
Crossgen2RuntimeIdentifiers="@(Crossgen2SupportedRids, '%3B')"
/>

Expand All @@ -588,6 +593,7 @@ Copyright (c) .NET Foundation. All rights reserved.
ILCompilerPackNamePattern="runtime.**RID**.Microsoft.DotNet.ILCompiler"
ILCompilerRuntimePackNamePattern="Microsoft.NETCore.App.Runtime.NativeAOT.**RID**"
ILCompilerPackVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)"
ILCompilerPortableRuntimeIdentifiers="@(ILCompilerSupportedPortableRids, '%3B')"
ILCompilerRuntimeIdentifiers="@(ILCompilerSupportedRids, '%3B')"
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,18 +802,31 @@ private ToolPackSupport AddToolPack(
{
var packNamePattern = knownPack.GetMetadata(packName + "PackNamePattern");
var packSupportedRuntimeIdentifiers = knownPack.GetMetadata(packName + "RuntimeIdentifiers").Split(';');
var packSupportedPortableRuntimeIdentifiers = knownPack.GetMetadata(packName + "PortableRuntimeIdentifiers").Split(';');

// When publishing for the non-portable RID that matches NETCoreSdkRuntimeIdentifier, prefer NETCoreSdkRuntimeIdentifier for the host.
// When publishing for a non-portable RID, 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.
// This makes non-portable SDKs behave the same as portable SDKs except for the specific case of targetting a non-portable RID.
// This ensures that targeting portable RIDs doesn't require any non-portable assets that aren't packaged in the SDK.
// Due to size concerns, the non-portable ILCompiler and Crossgen2 aren't included by default in non-portable SDK distributions.
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);
hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, hostRuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph);

// Prefer portable when the "supported RID" for the tool pack is the same RID as the "supported portable RID".
// This makes non-portable SDKs behave the same as portable SDKs except for the specific cases added to "supported", such as targeting the non-portable RID.
// This also ensures that targeting common RIDs doesn't require any non-portable assets that aren't packaged in the SDK by default.
// Due to size concerns, the non-portable ILCompiler and Crossgen2 aren't included by default in non-portable SDK distributions.
string supportedTargetRid = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedRuntimeIdentifiers, out _);
string supportedPortableTargetRid = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedPortableRuntimeIdentifiers, out _);

bool usePortable = !string.IsNullOrEmpty(NETCoreSdkPortableRuntimeIdentifier) && supportedTargetRid == supportedPortableTargetRid;

// 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
string hostRuntimeIdentifier = usePortable
? NuGetUtils.GetBestMatchingRid(runtimeGraph, NETCoreSdkPortableRuntimeIdentifier, packSupportedPortableRuntimeIdentifiers, out _)
: NuGetUtils.GetBestMatchingRid(runtimeGraph, NETCoreSdkRuntimeIdentifier, packSupportedRuntimeIdentifiers, out _);

if (hostRuntimeIdentifier == null)
{
return ToolPackSupport.UnsupportedForHostRuntimeIdentifier;
Expand Down