Skip to content

[build] Avoid archiving extracted library resources - #12447

Open
simonrozsival wants to merge 4 commits into
mainfrom
dev/simonrozsival/avoid-library-resource-archives
Open

[build] Avoid archiving extracted library resources#12447
simonrozsival wants to merge 4 commits into
mainfrom
dev/simonrozsival/avoid-library-resource-archives

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • compile extracted AAR and embedded-library resources directly from their resource directories
  • stop creating duplicate res.zip archives under obj/lp
  • avoid recursively checking and clearing read-only attributes on non-Windows systems
  • remove the obsolete resource-archive metadata path so stale archives from older builds cannot be consumed

Performance

In a clean MAUI Debug build, ResolveLibraryProjectImports fell from a median of about 5.8s to 3.3s. Compiling directories directly added only about 0.12s to AAPT2, for a net saving around 2.4s in this phase.

Validation

  • built Xamarin.Android.Build.Tasks.csproj
  • clean and no-op MAUI LLVM-IR builds
  • changed a resource inside a local AAR and confirmed the updated value in the packaged APK
  • confirmed clean builds produce no res.zip files

Related: #10958

Compile extracted Android library resources directly instead of duplicating them into res.zip archives. Avoid recursively clearing read-only attributes on non-Windows systems.

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:31

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 Android build pipeline by compiling extracted AAR and embedded-library resources directly from their resource directories, eliminating the intermediate res.zip archive step and related metadata so stale archives from older builds are not used.

Changes:

  • Remove creation/consumption of per-library res.zip resource archives and the associated ResourceDirectoryArchive item metadata.
  • Update ResolveLibraryProjectImports to stop generating archive paths and to only clear read-only attributes on Windows (avoiding expensive recursive scans on non-Windows).
  • Update AAPT2 compilation to compile resource directories directly (instead of optionally switching to a prebuilt zip archive).
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.EmbeddedResource.targets Stops tracking archived resource outputs (ResourceDirectoryArchive) as FileWrites, aligning cleanup/up-to-date tracking with the no-archive flow.
src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs Removes res.zip generation/metadata and limits recursive “make writeable” directory scans to Windows only.
src/Xamarin.Android.Build.Tasks/Tasks/CollectNonEmptyDirectories.cs Removes propagation of now-obsolete ResourceDirectoryArchive metadata from collected resource file items.
src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Compile.cs Removes logic that switches AAPT2 directory compilation to --zip based on ResourceDirectoryArchive, ensuring compilation uses resource directories directly.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer was cancelled. Please review the logs for details.

Generated by Android PR Reviewer for #12447

simonrozsival and others added 2 commits August 20, 2026 12:37
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 #12447

@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.

The resource-archive removal and Windows non-ASCII fallback look correct, and CI is green. I left one inline error-handling finding: temporary archive cleanup can mask the primary AAPT2 failure and stop cleaning subsequent files.

Generated by Android PR Reviewer for #12447 · gpt56 · 172.8 AIC · ⌖ 8.87 AIC · ⊞ 25.7K
Comment /review to run again

Comment thread src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Compile.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants