Skip to content

[build] Avoid staging unchanged framework assemblies - #12448

Open
simonrozsival wants to merge 2 commits into
mainfrom
dev/simonrozsival/avoid-framework-assembly-staging
Open

[build] Avoid staging unchanged framework assemblies#12448
simonrozsival wants to merge 2 commits into
mainfrom
dev/simonrozsival/avoid-framework-assembly-staging

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • identify framework assemblies that cannot contain Android types during ProcessAssemblies
  • skip Cecil processing and project-local DLL copies for those assemblies in Debug/no-shrink builds
  • package unchanged framework assemblies directly from their runtime-pack locations
  • retain project-local zero-byte scan markers for JCW and typemap consumers
  • continue fully processing Android framework assemblies such as Mono.Android and Java.Interop

I/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

  • built Xamarin.Android.Build.Tasks.csproj
  • clean and no-op MAUI LLVM-IR builds
  • confirmed Microsoft.CSharp.dll is packaged from the runtime pack and represented locally by a scan marker
  • confirmed Mono.Android.dll is still staged, scanned, and present in the generated native typemap
  • confirmed LinkAssembliesNoShrink is skipped on a no-op build
  • passed MultiTfmTransitiveReference CoreCLR regression coverage

Related: #10958

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
Copilot AI lite review requested due to automatic review settings August 19, 2026 15:35
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Android PR Reviewer. Review the logs for details.

Generated by Android PR Reviewer for #12448

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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)=True metadata for non-Android framework/runtime-pack assemblies during ProcessAssemblies.
  • Updates _LinkAssembliesNoShrink incrementalism 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
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12448

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Needs Changes — 0 errors, 1 warning, 0 suggestions.

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' ">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 ⚠️ Testing — This new branch changes the packaged DLL 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants