diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs index 25415800bf60..32b787991fc6 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs @@ -48,6 +48,8 @@ public class ProcessFrameworkReferences : TaskBase public bool AotEnabled { get; set; } + public bool AotUseKnownRuntimePackForTarget { get; set; } + public string RuntimeIdentifier { get; set; } public string[] RuntimeIdentifiers { get; set; } @@ -678,9 +680,10 @@ private bool AddToolPack( case ToolPackType.ILCompiler: HostILCompilerPacks = new[] { runtimePackItem }; - // ILCompiler supports cross target compilation. If there is a cross-target request, we need to download that package as well + // ILCompiler supports cross target compilation. If there is a cross-target request, + // we need to download that package as well unless we use KnownRuntimePack entries for the target. // We expect RuntimeIdentifier to be defined during publish but can allow during build - if (RuntimeIdentifier != null) + if (RuntimeIdentifier != null && !AotUseKnownRuntimePackForTarget) { var targetRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph2); if (targetRuntimeIdentifier == null) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props index 1c660c6e23cc..9aa86611864e 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props @@ -89,6 +89,11 @@ Copyright (c) .NET Foundation. All rights reserved. RuntimePackLabels="Mono" Condition="'$(UseMonoRuntime)' == 'true' And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '6.0')" /> + + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets index be84c3ca97a8..8c26d26d161a 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets @@ -101,6 +101,7 @@ Copyright (c) .NET Foundation. All rights reserved. ReadyToRunUseCrossgen2="$(PublishReadyToRunUseCrossgen2)" TrimmingEnabled="$(_IsTrimmingEnabled)" AotEnabled="$(PublishAot)" + AotUseKnownRuntimePackForTarget="$(PublishAotUsingRuntimePack)" RuntimeIdentifier="$(RuntimeIdentifier)" RuntimeIdentifiers="$(RuntimeIdentifiers)" RuntimeFrameworkVersion="$(RuntimeFrameworkVersion)"