Skip to content
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

Select the NativeAOT runtime pack as the target package when it's provided as part of the KnownILCompilerPack metadata #46611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -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).
Comment on lines +850 to +851
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the mention of the host pack a little confusing since we already pull a separate target-specific package when needed. I'd change this to "If there's an available runtime pack, use it instead of the ILCompiler package for target-specific bits." or something along those lines.

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
Loading