[build] Avoid staging unchanged framework assemblies - #12448
[build] Avoid staging unchanged framework assemblies#12448simonrozsival wants to merge 2 commits into
Conversation
Package non-Android framework assemblies directly from runtime packs instead of opening and copying them into project intermediates. Keep project-local zero-byte scan markers for downstream typemap and JCW consumers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6469f820-c19a-4450-8bb9-de70387d899c
|
/review |
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes the .NET for Android build pipeline by identifying framework/runtime-pack assemblies that cannot contain Android types and avoiding unnecessary staging/copying and Cecil-based processing for those assemblies in Debug/no-shrink scenarios, while preserving the scan “sidecar” contract via zero-byte markers.
Changes:
- Introduces
%(AndroidSkipAssemblyModification)=Truemetadata for non-Android framework/runtime-pack assemblies duringProcessAssemblies. - Updates
_LinkAssembliesNoShrinkincrementalism and processing to emit a single zero-byte scan marker (.scan.empty) instead of staging the DLL for those assemblies. - Updates JCW and typemap consumers to resolve sidecar paths from item metadata when provided (falling back to the historical “next to assembly” convention otherwise), enabling the marker-based flow.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Splits resolved assemblies/symbols into “link-no-shrink” vs “package without modification” groups and updates _LinkAssembliesNoShrink Outputs to include marker files for skipped assemblies. |
| src/Xamarin.Android.Build.Tasks/Utilities/TypeMapObjectsXmlFile.cs | Adds ITaskItem overload to resolve typemap XML path from item metadata (supporting marker files). |
| src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs | Switches typemap lookup to the new ITaskItem-aware path resolver. |
| src/Xamarin.Android.Build.Tasks/Utilities/JavaObjectsXmlFile.cs | Adds ITaskItem overload to resolve JLO XML path from item metadata (supporting marker files). |
| src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs | Sets FrameworkAssembly, HasMonoAndroidReference, and new AndroidSkipAssemblyModification metadata (including for symbol items). |
| src/Xamarin.Android.Build.Tasks/Tasks/LinkAssembliesNoShrink.cs | Skips the pipeline for marked assemblies and writes a zero-byte .scan.empty marker file. |
| src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaCallableWrappers.cs | Uses the ITaskItem-aware JLO path resolver so marker files work. |
| src/Xamarin.Android.Build.Tasks/Tasks/GenerateACWMap.cs | Uses the ITaskItem-aware JLO path resolver so marker files work. |
| src/Xamarin.Android.Build.Tasks/Tasks/AssemblyModifierPipeline.cs | Adds an overridable fast-path hook (TryProcessWithoutPipeline) used by LinkAssembliesNoShrink. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets | Updates _PrepareAssemblies to stage only modified assemblies while keeping non-Android framework assemblies sourced from runtime-pack locations. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 0
- Review effort level: Lite
Keep conditional output metadata on the original ResolvedAssemblies items so MSBuild can correlate inputs and outputs during partial builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 986b59ba-93bf-46dc-a6c0-4f01dd7e2b3f
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
The runtime-pack optimization is coherently wired through assembly classification, marker creation, MSBuild item transforms, and both scanner consumers. CI build 1560590 and all reported checks are green. The remaining concern is automated regression coverage for the new packaging/marker/no-op path; the existing test cited in the PR does not exercise that branch.
Generated by Android PR Reviewer for #12448 · gpt56 · 254.2 AIC · ⌖ 8.93 AIC · ⊞ 25.7K
Comment /review to run again
| Condition=" '%(ResolvedAssemblies.AndroidSkipAssemblyModification)' != 'True' " /> | ||
| <_AndroidAssembliesToPackageWithoutLinkNoShrink | ||
| Include="@(ResolvedAssemblies)" | ||
| Condition=" '%(ResolvedAssemblies.AndroidSkipAssemblyModification)' == 'True' "> |
There was a problem hiding this comment.
🤖 ItemSpec and replaces two independently consumed scanner sidecars with a shared marker, but the PR adds no regression assertion for that behavior. MultiTfmTransitiveReference only verifies an Android user assembly's .jlo.xml; it would still pass if this branch stopped packaging a skipped framework DLL or lost either marker metadata value. Please add a no-shrink build test that verifies a non-Android framework assembly is packaged from its runtime-pack path, both sidecar metadata values resolve to a zero-byte marker, an Android framework assembly remains staged/scanned, and the second build skips LinkAssembliesNoShrink.
Rule: Regression coverage
Summary
ProcessAssembliesMono.AndroidandJava.InteropI/O impact
For a clean MAUI Debug LLVM-IR build on arm64, the assembly staging directory changed from approximately 327 DLLs / 160.6 MiB to 145 DLLs / 93.3 MiB. This avoids 182 DLL copies and about 67 MiB of project-local staging writes.
Validation
Xamarin.Android.Build.Tasks.csprojMicrosoft.CSharp.dllis packaged from the runtime pack and represented locally by a scan markerMono.Android.dllis still staged, scanned, and present in the generated native typemapLinkAssembliesNoShrinkis skipped on a no-op buildMultiTfmTransitiveReferenceCoreCLR regression coverageRelated: #10958