Skip to content

[release/11.0.1xx-rc1] Fix incremental APK archives and NuGet cache writes - #12463

Open
jonathanpeppers wants to merge 2 commits into
release/11.0.1xx-rc1from
jonathanpeppers-rc1-bug-backports
Open

[release/11.0.1xx-rc1] Fix incremental APK archives and NuGet cache writes#12463
jonathanpeppers wants to merge 2 commits into
release/11.0.1xx-rc1from
jonathanpeppers-rc1-bug-backports

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

RC1 justification

These are narrowly scoped customer-facing correctness and reliability fixes. They prevent stale or incorrect APK contents during incremental builds, prevent mutation of NuGet package-cache assemblies, and avoid concurrent-build XAAMP7024 failures caused by writes to shared cached satellite assemblies.

There are no public API changes and no dependency changes.

Validation

  • PASS: BuildArchiveTests — 4 passed, 0 failed.
  • PASS: Xamarin.Android.Build.Tests and its product dependencies compiled successfully with the host .NET 11 SDK after building the existing bootstrap task prerequisites.
  • PASS: Xamarin.Android.Common.targets XML validation.
  • The BuildDoesNotModifyNuGetPackageCache integration test compiled and started, but could not execute its nested app build because this checkout does not contain the repo-local SDK at bin\Debug\dotnet\dotnet; CI should provide full-build coverage.

Upstream references: #11552 and #12450.

Copilot AI and others added 2 commits August 20, 2026 12:34
* Initial plan

* Fix BuildArchive jar entry retention

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Update stale BuildArchive jar entries

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Cover up-to-date BuildArchive jar entries

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Address BuildArchive review feedback

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Address BuildArchive validation feedback

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Address review: null-check jar.ReadEntry result; create secondJar on disk in duplicate test

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Address review: consistent log path format, re-add stale entry to cleanup on missing jar entry, add null-jar-entry test

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Address review: [] collection expressions in tests, CRC comment, ContainsEntry before ReadEntry

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>

* Test consecutive BuildArchive updates

Exercise three unchanged archive builds so the regression test detects the original alternating JAR-entry removal while continuing to verify stale-entry cleanup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3f5c44bc-27d8-41e9-b3ae-8585e08c00de

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Šimon Rozsíval <simon@rozsival.com>
Copilot-Session: 3f5c44bc-27d8-41e9-b3ae-8585e08c00de
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5834c55d-890a-4cd1-9451-8fa37964e0a9
## Description

Android builds must treat the NuGet global package cache as read-only. However, satellite `*.resources.dll` files from NuGet packages were included in `ResolvedAssemblies` and passed to `AssemblyModifierPipeline` using their original package-cache paths.

When marshal methods were enabled, `_RunAfterILLinkAdditionalSteps` ran this pipeline in place. Even unchanged assemblies had their timestamps updated, and concurrent builds could fail when they attempted to write the same cached file.

Exclude satellite resource assemblies from the post-link modifier input only when the pipeline operates in place. The assemblies remain in the normal resolved-assembly flow, so they are still packaged, and non-in-place post-link processing is unchanged.

Add a regression test using `Humanizer.Core.es` from the public `dotnet-public` feed. It locks the package's resource assemblies and verifies that the build neither writes to them nor changes their timestamps.

## Tests

- `BuildDoesNotModifyNuGetPackageCache`
- `CheckIncludedAssemblies(True, CoreCLR)`

Fixes #11022

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5834c55d-890a-4cd1-9451-8fa37964e0a9
Copilot AI lite review requested due to automatic review settings August 20, 2026 17:39

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

Backport of two customer-facing build correctness fixes into the release/11.0.1xx-rc1 branch: (1) make incremental BuildArchive updates correctly retain/replace/remove JAR-sourced APK entries, and (2) prevent in-place post-link processing from mutating satellite assemblies located in the NuGet global packages cache (avoiding cache corruption and concurrent-build write failures).

Changes:

  • Update BuildArchive to distinguish existing output entries vs. current-build duplicates, skip up-to-date JAR entries, replace stale entries, and remove entries when the source JAR entry is missing.
  • Filter AssemblyModifierPipeline in-place inputs to exclude *.resources.dll assemblies to avoid writes into the NuGet package cache.
  • Add regression tests covering both the incremental APK archive behavior and the NuGet cache immutability scenario.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets Filters post-link in-place SourceFiles to exclude satellite resource assemblies so NuGet cache files aren’t touched.
src/Xamarin.Android.Build.Tasks/Tasks/BuildArchive.cs Improves incremental archive update logic for existing JAR-sourced entries (skip/replace/remove correctly).
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/BuildArchiveTests.cs Adds focused unit tests validating incremental behavior for existing JAR entries.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs Adds integration regression test ensuring builds don’t write to/retimestamp NuGet cached satellite assemblies.

Comment thread src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Aug 20, 2026
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) August 20, 2026 20:19
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

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

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants