Skip to content

Commit

Permalink
Select the NativeAOT runtime pack as the target package when it's pro…
Browse files Browse the repository at this point in the history
…vided as part of the KnownILCompilerPack metadata.

Depends on dotnet/runtime#111876
  • Loading branch information
jkoritzinsky committed Jan 31, 2025
1 parent 83cd168 commit 9fa393b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<KnownILCompilerPack Include="Microsoft.DotNet.ILCompiler"
TargetFramework="net10.0"
ILCompilerPackNamePattern="runtime.**RID**.Microsoft.DotNet.ILCompiler"
ILCompilerRuntimePackNamePattern="Microsoft.NETCore.App.Runtime.NativeAOT.**RID**"
ILCompilerPackVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)"
ILCompilerRuntimeIdentifiers="@(ILCompilerSupportedRids, '%3B')"
/>
Expand Down
15 changes: 13 additions & 2 deletions src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,20 @@ private ToolPackSupport AddToolPack(
{
return ToolPackSupport.UnsupportedForTargetRuntimeIdentifier;
}
if (!hostRuntimeIdentifier.Equals(targetRuntimeIdentifier))

// If we have a separate pack pattern for the runtime pack,
// we should always use the runtime pack (the host pack may not have the tooling we need for the target).
bool useRuntimePackForAllTargets = false;
string targetPackNamePattern = packNamePattern;
if (knownPack.GetMetadata("ILCompilerRuntimePackNamePattern") is string runtimePackNamePattern)
{
targetPackNamePattern = runtimePackNamePattern;
useRuntimePackForAllTargets = true;
}

if (useRuntimePackForAllTargets || !hostRuntimeIdentifier.Equals(targetRuntimeIdentifier))
{
var targetIlcPackName = packNamePattern.Replace("**RID**", targetRuntimeIdentifier);
var targetIlcPackName = targetPackNamePattern.Replace("**RID**", targetRuntimeIdentifier);
var targetIlcPack = new TaskItem(targetIlcPackName);
targetIlcPack.SetMetadata(MetadataKeys.NuGetPackageId, targetIlcPackName);
targetIlcPack.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);
Expand Down

0 comments on commit 9fa393b

Please sign in to comment.