Conversation
…one MSBuild task and pipeline step Move embedded resource stripping out of the ILLink custom step so it runs after ILLink but before ReadyToRun/crossgen2 in the inner build, ensuring R2R images are generated from already-stripped assemblies. - Trimmed builds: new StripEmbeddedLibraries MSBuild task runs via _StripEmbeddedLibraries target (AfterTargets="ILLink") in the inner build, processing assemblies in-place with temp-write-copy-back. - Non-trimmed builds: new StripEmbeddedLibrariesStep added to LinkAssembliesNoShrink pipeline. - Shared ShouldStripResource() logic between both paths. - Removed old _TrimmerCustomSteps registration and deleted the ILLink StripEmbeddedLibraries.cs (now dead code).
…er with search directories When Cecil writes a modified assembly, it resolves type references during metadata building (MetadataBuilder.GetConstantType). Without an assembly resolver configured with search directories, this fails with AssemblyResolutionException for references like Mono.Android. Add a DefaultAssemblyResolver populated with unique directories from the assembly list, matching the pattern used by AssemblyModifierPipeline.
…andles before file copy-back
There was a problem hiding this comment.
Pull request overview
This PR moves the StripEmbeddedLibraries logic from an ILLink custom step to a standalone MSBuild task that runs after ILLink but before ReadyToRun/crossgen2, ensuring R2R images are generated from already-stripped assemblies. For non-trimmed builds, a new StripEmbeddedLibrariesStep pipeline step handles stripping in LinkAssembliesNoShrink.
Changes:
- New
StripEmbeddedLibrariesMSBuild task and_StripEmbeddedLibrariestarget for trimmed builds - New
StripEmbeddedLibrariesSteppipeline step for non-trimmed builds, reusing sharedShouldStripResource()logic - Removed old ILLink
StripEmbeddedLibrariescustom step and its_TrimmerCustomStepsregistration
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs |
New MSBuild task for stripping embedded resources from trimmed assemblies |
src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/StripEmbeddedLibrariesStep.cs |
New pipeline step for non-trimmed builds |
src/Xamarin.Android.Build.Tasks/Tasks/LinkAssembliesNoShrink.cs |
Adds the new step to the non-trimmed pipeline |
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets |
Registers task, adds target, removes old custom step |
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj |
Includes new step source file |
src/Microsoft.Android.Sdk.ILLink/StripEmbeddedLibraries.cs |
Deleted old ILLink step |
jonathanpeppers
left a comment
There was a problem hiding this comment.
🤖 AI Review Summary
Verdict:
Found 3 issues (3 warnings, 1 suggestion):
⚠️ Nullable:StripEmbeddedLibrariesStep.csmissing#nullable enable(StripEmbeddedLibrariesStep.cs:1)⚠️ Error handling: Empty catch block silently swallowsException(StripEmbeddedLibraries.cs:113)⚠️ Error codes:Log.LogWarningshould useLog.LogCodedWarningwith XA code (StripEmbeddedLibraries.cs:173)- 💡 MSBuild targets:
AfterTargets="ILLink"should check$(MSBuildLastTaskResult)(TypeMap.LlvmIr.targets:260)
👍 Clean architecture — splitting the ILLink custom step into a shared ShouldStripResource() with both a pipeline step (non-trimmed) and MSBuild task (trimmed) is well-designed. The temp-write-copy-back pattern in the task avoids file locking issues. Good documentation in the target comments explaining when each path runs.
Review generated by android-reviewer from review guidelines.
src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/StripEmbeddedLibrariesStep.cs
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tasks/StripEmbeddedLibraries.cs
Outdated
Show resolved
Hide resolved
...droid.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets
Show resolved
Hide resolved
…ition - Add #nullable enable to StripEmbeddedLibrariesStep.cs - Log exceptions in catch blocks instead of silently swallowing them - Downgrade RemoveFile warning to LogDebugMessage (matches prevailing pattern for temp file cleanup failures) - Add MSBuildLastTaskResult check to _StripEmbeddedLibraries target to skip when ILLink fails
(Trying as an alternative to #10695 that should have fewer build changes, and avoids stripping R2R info from assemblies.)
Move embedded resource stripping out of the ILLink custom step so it runs after ILLink but before ReadyToRun/crossgen2 in the inner build, ensuring R2R images are generated from already-stripped assemblies.