Skip to content

Migrate GenerateProguardConfiguration from ILLink step to MSBuild task#10694

Merged
jonathanpeppers merged 8 commits intomainfrom
dev/sbomer/proguard-step
Feb 13, 2026
Merged

Migrate GenerateProguardConfiguration from ILLink step to MSBuild task#10694
jonathanpeppers merged 8 commits intomainfrom
dev/sbomer/proguard-step

Conversation

@sbomer
Copy link
Copy Markdown
Member

@sbomer sbomer commented Jan 14, 2026

The new task runs AfterTargets="ILLink" and uses System.Reflection.Metadata instead of Mono.Cecil to scan linked assemblies.

The new task runs AfterTargets="ILLink" and uses System.Reflection.Metadata
instead of Mono.Cecil to scan linked assemblies.
@jonathanpeppers
Copy link
Copy Markdown
Member

Looking at the test failures, I think this might have broken Proguard rules on NativeAOT:

image

I'll rerun to verify.

Copilot AI review requested due to automatic review settings February 3, 2026 23:25
@sbomer sbomer requested a review from simonrozsival as a code owner February 3, 2026 23:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the GenerateProguardConfiguration functionality from an ILLink custom step (using Mono.Cecil) to an MSBuild task (using System.Reflection.Metadata). The task runs after the ILLink target and scans linked assemblies to generate ProGuard configuration rules for Android callable wrapper (ACW) types.

Changes:

  • Added new MSBuild task GenerateProguardConfiguration using System.Reflection.Metadata for assembly inspection
  • Updated MSBuild targets to invoke the new task after ILLink instead of as a linker custom step
  • Removed the old ILLink step implementation that used Mono.Cecil

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/Xamarin.Android.Build.Tasks/Tasks/GenerateProguardConfiguration.cs New MSBuild task that scans linked assemblies for RegisterAttribute and generates ProGuard keep rules
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets Added targets to prepare linked assemblies and invoke the new task; removed old linker custom step configuration
src/Microsoft.Android.Sdk.ILLink/GenerateProguardConfiguration.cs Deleted old ILLink step implementation

Comment thread src/Xamarin.Android.Build.Tasks/Tasks/GenerateProguardConfiguration.cs Outdated
Comment thread src/Xamarin.Android.Build.Tasks/Tasks/GenerateProguardConfiguration.cs Outdated
@sbomer sbomer closed this Feb 8, 2026
@sbomer sbomer reopened this Feb 8, 2026
@sbomer
Copy link
Copy Markdown
Member Author

sbomer commented Feb 8, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

sbomer and others added 4 commits February 11, 2026 17:22
In NativeAOT builds, ResolvedFileToPublish is not populated until
_AndroidComputeIlcCompileInputs runs (after ILLink), so the proguard
generation targets were reading an empty assembly list and missing the
entry-point assembly. This caused R8 to strip Java classes needed at
runtime, resulting in ClassNotFoundException.

Use a property-based AfterTargets approach: _GenerateProguardAfterTargets
defaults to ILLink for the standard path, and NativeAOT.targets overrides
it to _AndroidComputeIlcCompileInputs. Also switch from ManagedAssemblyToLink
(which never includes the entry-point assembly) to ResolvedFileToPublish
filtered to .dll, which correctly includes all assemblies in both paths.
# Conflicts:
#	src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
…ation.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ation.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sbomer
Copy link
Copy Markdown
Member Author

sbomer commented Feb 13, 2026

@jonathanpeppers I think this is ready to go, PTAL!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

@jonathanpeppers jonathanpeppers merged commit 4eecaa7 into main Feb 13, 2026
12 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/sbomer/proguard-step branch February 13, 2026 22:45
@jonathanpeppers jonathanpeppers added the copilot `copilot-cli` or other AIs were used to author this label Feb 13, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

copilot `copilot-cli` or other AIs were used to author this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants