From 2e79fa317763289c447ee07f54373b711196c2aa Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 21 Apr 2026 16:11:33 -0700 Subject: [PATCH 1/2] Make PrepareTrimConfiguration a public extension point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename _PrepareTrimConfiguration to PrepareTrimConfiguration so that external SDKs (e.g. MAUI) can hook BeforeTargets="PrepareTrimConfiguration" to add RuntimeHostConfigurationOption items before they are snapshotted into _TrimmerFeatureSettings. PR #124801 extracted the RHCO → _TrimmerFeatureSettings conversion from PrepareForILLink into _PrepareTrimConfiguration, which runs as a dependency of PrepareForILLink. This caused MAUI's feature switches (added via BeforeTargets="PrepareForILLink") to arrive after the snapshot, so ILC never received --feature flags for switches like IsHybridWebViewSupported. The result was spurious IL3050 warnings on Android NativeAOT where RunILLink=true. Making the target public gives SDKs a stable, intentional hook point for adding feature switch configuration that flows to both ILLink and ILC. Fixes #127017 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: Claude:claude-opus-4.6-1m --- .../Microsoft.NETCore.Native.Publish.targets | 6 +++--- .../ILLink.Tasks/build/Microsoft.NET.ILLink.targets | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets index bf473414890f6c..487271bdf16608 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets @@ -3,7 +3,7 @@ + DependsOnTargets="$(IlcDynamicBuildPropertyDependencies);_ComputeAssembliesToCompileToNative;PrepareTrimConfiguration"> <_IlcManagedInputAssemblies Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.PostprocessAssembly)' == 'true'" /> @@ -24,7 +24,7 @@ The SDK typically sequences this target in the publish pipeline as: ComputeResolvedFilesToPublishList -> ILLink (when RunILLink is true) -> NativeCompile -> ... - This gives us a clean, explicit position after trim configuration (_PrepareTrimConfiguration), + This gives us a clean, explicit position after trim configuration (PrepareTrimConfiguration), regardless of whether ILLink itself runs. ============================================================ --> @@ -84,7 +84,7 @@ + BeforeTargets="PrepareTrimConfiguration"> diff --git a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets index 92976f23cd65ba..8d89a954a0e330 100644 --- a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets +++ b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets @@ -195,7 +195,7 @@ Copyright (c) .NET Foundation. All rights reserved. - @@ -335,7 +339,7 @@ Copyright (c) .NET Foundation. All rights reserved. ============================================================ --> - + From e190b4816230e6faf170eba71d9d2eccae1471a6 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 22 Apr 2026 07:35:15 +0800 Subject: [PATCH 2/2] Clarify comment Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets index 8d89a954a0e330..1c3af30514ab6f 100644 --- a/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets +++ b/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets @@ -204,8 +204,9 @@ Copyright (c) .NET Foundation. All rights reserved. ResolvedFileToPublish items for the intermediate assembly and project references. This is a public extension point. Other targets may hook into it via - BeforeTargets="PrepareTrimConfiguration" to add RuntimeHostConfigurationOption items - that will be included in _TrimmerFeatureSettings for both ILLink and ILC. + BeforeTargets="PrepareTrimConfiguration" to add RuntimeHostConfigurationOption items. + Only items with Trim="true" metadata will be included in _TrimmerFeatureSettings + for both ILLink and ILC. Consumers that need trim metadata on ResolvedFileToPublish should depend on this target. Metadata set here flows to ManagedAssemblyToLink via _ComputeManagedAssemblyToLink (which