Skip to content

[Build.Tasks] Remove legacy Android tooling resolution - #13161

Merged
simonrozsival merged 2 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-legacy-tooling-cleanup
Oct 19, 2026
Merged

simonrozsival merged 2 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-legacy-tooling-cleanup

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

Product targets already use Xamarin.Android.Tasks.ResolveAndroidTooling. Only the old SDK test fixture references Xamarin.Android.Tasks.Legacy.ResolveAndroidTooling, so keeping the wrapper maintains unused Xamarin-era framework mapping and obsolete diagnostics without exercising the shipping task in those tests.

Delete the wrapper and migrate its parameterized and timing coverage to the modern task's TargetPlatformVersion, AndroidApiLevel, and AndroidApiLevelName. Cover stable, preview, minor-version, missing/invalid-version fallback, AAPT2 caching, and missing-tool errors. Preserve SDK/tool path assertions, discovery-state isolation, absolute paths, Java validation, and redundant-output-logging assertions.

Remove the now-unused subclass hooks and inputs (Validate, LogOutputs, ProjectFilePath, and AndroidApplication) and their target arguments. Remove exactly six wrapper-only resources from the English resource file and designer: XA0001, XA0113, XA0117, and the three framework-mapping XA0000 variants. Retain the general XA0000 exception diagnostic, all non-English localization files, and historical documentation URLs; mark the retired diagnostics as legacy.

MonoAndroidHelper.SupportedVersions, SDK discovery, Java validation, caching implementation, and nested-build forwarding are unchanged. This is an independent cleanup from main at bcdef48, not a stacked PR. No issue is closed, and no wall-time or task-wide thread-safety improvement is claimed.

Local validation

Windows; prepared and built this isolated worktree's SDK (12.0.100-alpha.1.26509.101, targeting .NET 11), not an installed workload or another worktree's binaries. Build/test processes set DOTNET_CLI_USE_MSBUILD_SERVER=0, MSBUILDDISABLENODEREUSE=1, DOTNET_CLI_TELEMETRY_OPTOUT=1, and TEST_ANDROID_JDK_PATH=C:\Program Files\Android\openjdk\jdk-21.0.8. SDK builds run after C:\Program Files\Microsoft Visual Studio\18\Insiders\Common7\Tools\VsDevCmd.bat in the same cmd process.

  • .\build.cmd Prepare — passed.
  • .\dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -nr:false -v:minimal -bl:C:\Users\jopepper\.copilot\session-state\10692d52-13c3-4c9b-b46d-96de1b3f92b5\files\final-build.binlog — passed, 0 errors, 92 existing warnings (the comparison build with original tooling also has 92 warnings).
  • .\dotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~ResolveSdksTaskTests|FullyQualifiedName~ValidateJavaVersionTests|FullyQualifiedName~InvalidTargetPlatformVersion" --logger "trx;LogFileName=final-tooling.trx" --results-directory "C:\Users\jopepper\.copilot\session-state\10692d52-13c3-4c9b-b46d-96de1b3f92b5\files\test-results" — passed, 53/53, no skips. Invoked through cmd /c to preserve the filter's pipe characters.
  • .\dotnet-local.cmd build bin\TestDebug\temp\BuildBasicApplicationCheckPdbRepeatBuildCoreCLR\UnnamedProject.csproj -t:Rebuild,SignAndroidPackage @bin\TestDebug\temp\BuildBasicApplicationCheckPdbRepeatBuildCoreCLR\project.rsp -nr:false -v:minimal -bl:C:\Users\jopepper\.copilot\session-state\10692d52-13c3-4c9b-b46d-96de1b3f92b5\files\app-rebuild-confirm.binlog — passed, 0 warnings/errors; signed APK produced.
  • .\dotnet-local.cmd build bin\TestDebug\temp\BuildBasicApplicationCheckPdbRepeatBuildCoreCLR\UnnamedProject.csproj -t:Build,SignAndroidPackage @bin\TestDebug\temp\BuildBasicApplicationCheckPdbRepeatBuildCoreCLR\project.rsp -nr:false -v:minimal -bl:C:\Users\jopepper\.copilot\session-state\10692d52-13c3-4c9b-b46d-96de1b3f92b5\files\app-incremental-confirm.binlog — passed, 0 warnings/errors. The generated response file selects this host's Android SDK/NDK and JDK 21.
  • git diff --check, resource/target XML parsing, exact resource-removal comparison, and remaining-consumer/localization checks — passed. Inspected build/application binlogs using binlogtool.

Existing additional-test failure

The initial combined run additionally selected BuildBasicApplicationCheckPdbRepeatBuild(CoreCLR): 51 passed, 1 failed. Its app build succeeds, but the test then expects obj\Debug\android\assets\x86_64\UnnamedProject.pdb; that file is absent (the arm64-v8a PDB is present).

Reproduced the identical assertion after restoring ResolveAndroidTooling.cs and Microsoft.Android.Sdk.Tooling.targets to their original main versions, rebuilding the local SDK, and running:

.\dotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~BuildBasicApplicationCheckPdbRepeatBuild" --logger "trx;LogFileName=baseline-pdb.trx" --results-directory "C:\Users\jopepper\.copilot\session-state\10692d52-13c3-4c9b-b46d-96de1b3f92b5\files\test-results" — same 1/1 failure.

The cleanup was restored and the full local SDK rebuilt before the final 53-case passing run and direct app build checks above. The unrelated PDB-location test is not modified by this PR. Device tests are not applicable to this host-only task cleanup.

Product targets already use Xamarin.Android.Tasks.ResolveAndroidTooling.
Only the old SDK fixture still exercises the Xamarin-era wrapper.

Migrate its platform and timing coverage to the shipping task, retain SDK
and Java validation, and cover current platform fallback and tooling
errors.  Remove unused subclass hooks and inputs together with six
wrapper-only resource entries.  Preserve historical diagnostic links and
mark their legacy behavior explicitly.

Leave SupportedVersions and SDK discovery behavior unchanged.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 10692d52-13c3-4c9b-b46d-96de1b3f92b5
Copilot AI balanced review requested due to automatic review settings October 15, 2026 18:46

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.

🟡 Changes recommended

Two new tests depend on prior global initialization and fail when run independently.

1 open finding
What changed in this PR

Removes the unused Xamarin-era tooling resolver and moves its coverage to the shipping .NET for Android task.

Changes:

  • Deletes the legacy wrapper, unused hooks, and task inputs.
  • Migrates API-resolution tests and adds caching and missing-tool coverage.
  • Removes six obsolete resources and marks historical diagnostics as legacy.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ResolveSdksTaskTests.cs Migrates and expands modern resolver tests.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ResolveAndroidTooling.cs Removes unused inputs and subclass hooks.
src/​Xamarin.Android.Build.Tasks/​Tasks/​Legacy/​ResolveAndroidTooling.cs Deletes the legacy resolver.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.resx Removes six wrapper-only resources.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.Designer.cs Removes corresponding resource accessors.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.Tooling.targets Removes obsolete task arguments.
Documentation/​docs-mobile/​TOC.yml Labels retired diagnostics as legacy.
Documentation/​docs-mobile/​messages/​xa0117.md Clarifies historical applicability.
Documentation/​docs-mobile/​messages/​xa0113.md Distinguishes historical Google Play requirements.
Documentation/​docs-mobile/​messages/​xa0001.md Marks framework validation as legacy.
Documentation/​docs-mobile/​messages/​xa0000.md Marks framework mapping as legacy.
Documentation/​docs-mobile/​messages/​index.md Updates diagnostic summaries.
Files not reviewed (1)
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file

🧠 Review effort: Balanced

Initialize SupportedVersions explicitly in both new tooling tests.
Without this setup they depend on an earlier ResolveSdks test and fail
when selected independently in a fresh test process.

Both individual filters now pass, and the focused SDK, Java and platform
validation suite passes all 53 cases.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 10692d52-13c3-4c9b-b46d-96de1b3f92b5
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Oct 16, 2026
@simonrozsival
simonrozsival enabled auto-merge (squash) October 19, 2026 10:33
@simonrozsival
simonrozsival merged commit 3ed4e83 into dotnet:main Oct 19, 2026
41 checks passed
simonrozsival pushed a commit that referenced this pull request Oct 20, 2026
…te (#13201)

`Xamarin.Android.Tasks.MonoAndroidHelper.SupportedVersions` is a mutable process-wide value. One project can replace the API data that another task uses. Remove that value and `RefreshSupportedVersions`, and pass `ReferenceAssemblyPaths` to each consumer.

SDK discovery, Java validation, and legacy-tool cleanup are already merged in #13145, #13133, and #13161. This PR does not repeat those changes. It is the lower prerequisite for a separate nested-build optimization. **SDK and Java resolution call counts are unchanged**, including inner builds.

Cache read-only `AndroidVersions` data through `IBuildEngine4` with `RegisteredTaskObjectLifetime.Build`. The key includes the task assembly identity and the absolute, original input directory list. The cache holds no task logger or mutable current-context pointer. Concurrent creation for an equal key is harmless; correctness does not depend on a cache shared across worker processes or assembly load contexts.

All API-data consumers use explicit inputs: platform JAR and tooling resolution, manifests, aapt2, D8/R8, signing, jar2xml, launch activity/instrumentation, library resources, and dependency calculation. `ManifestDocument` keeps its own version resolver, with a known-version default for standalone use. Aapt2Link and library-resource generation resolve API metadata on the calling thread before yielding.

The concurrency test runs 64 tasks against two different SDK/API datasets that map the same preview ID `Z` to API levels 127 and 128. It checks both JAR paths and API outputs. The aapt2 tests link two ABIs and require exactly one API lookup before `Yield`, with relative reference paths resolved from the task's captured working directory. Tests also check cache reuse, separate build engines, manifest resolver isolation, and library-resource metadata access before `Yield`.
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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