Skip to content

[Xamarin.Installer.Build.Tasks] Roll platform-tools forward within major - #13691

Open
jonathanpeppers wants to merge 4 commits into
mainfrom
jonathanpeppers-platform-tools-roll-forward
Open

jonathanpeppers wants to merge 4 commits into
mainfrom
jonathanpeppers-platform-tools-roll-forward

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Context: #13666, #13646, #13644

Follows #13666 (platform-tools 37.0.3 bump).

InstallAndroidDependenciesTest failed because Android CLI 1.1.16717390 returned success for [email protected] while logging No url for platform-tools. Ignoring.. Google replaces platform-tools point releases in its catalog, so moving the shipped installer to another exact point release only postpones the same failure.

The <InstallAndroidDependencies/> task now queries android --no-metrics --sdk=<path> sdk list --all --all-versions platform-tools at installation time. It selects the numerically newest stable version listed as available that is at least the requested version and has the same major version. The default stays within 37.x: 37.0.1 can roll to 37.0.3, but 38.x and previews are never selected automatically. $(AndroidSdkPlatformToolsVersion) remains a minimum, so requesting 37.5 never silently installs 37.0.3; an explicit override with another major selects that band. Only the catalog's available section is considered (the CLI also lists installed packages there). Older installed tools are updated; equal or newer installed versions are left alone. An installed preview, such as 37.0.3-rc1, does not satisfy the stable release with the same number. When the license check is necessary, it runs after this selection, so AcceptAndroidSDKLicenses=false fails only when a package must be installed.

New errors, instead of installing another major or guessing a fallback:

  • XA5309: the catalog command failed. The message contains the end of the CLI's standard output and standard error.
  • XA5310: no sufficient stable version in the requested major is listed.
  • XA5311: the requested platform-tools version is malformed.

An empty platform-tools Version keeps the previous unversioned behavior (no catalog query). Other dependencies keep accepting nonnumeric versions such as cmdline-tools/latest. The existing SDK package-list parser is shared through SdkPackageListParser.cs, without public API or signing changes.

The repository's fixed 37.0.3 provisioning URLs/hashes and workload feed entry are unchanged. The Android CLI executable remains SHA-256 pinned; dynamically selected SDK archives trust Google's HTTPS catalog and its checksums.

Windows test fix

On Windows CI (build 1692300), 9 new tests failed in all MSBuild Tests Windows jobs (for example PlatformToolsCatalogFailureStopsInstallation: expected XA5309, got XA5310); they passed on Linux. The fake android.cmd checked if "%4"=="list", but cmd.exe splits --sdk=C:\... at =, so list is %5. The catalog call went to the install branch and returned an empty catalog with exit code 0. Both fake CLIs now search for a list token instead of a fixed position. PlatformToolsCatalogFailureStopsInstallation also now deletes its temp folder first, like the other tests, so a stale args.txt cannot make it fail.

Validation

Windows x64, local Debug SDK built with build.cmd (passed):

  • dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -c Debug: passed, 0 warnings/errors.
  • bin\Debug\dotnet\dotnet.exe test bin\TestDebug\net11.0\Xamarin.Android.Build.Tests.dll --filter "Name~PlatformTools|Name~InstallAndroidDependenciesPassesPackagesToAndroidCli" (with the dotnet-local.cmd workload environment; dotnet-local.cmd cannot pass a | filter): passed, 19/19, on two consecutive runs. This includes the preview-installed and AcceptAndroidSDKLicenses=false cases.
  • Same command with the old %4 stub: failed, 9/16, the same tests as CI.
  • Same command without the XA5309 and preview changes in the task: failed, 2/19 (PlatformToolsCatalogFailureStopsInstallation, PlatformToolsPreviewInstalled).
  • dotnet test tests\Xamarin.Android.Tools.AndroidSdk-Tests\Xamarin.Android.Tools.AndroidSdk-Tests.csproj -p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=10.0 --filter "FullyQualifiedName~ParseSdkManagerList": passed, 6/6.

Earlier validation on macOS Arm64 (from #13666, same feature code): the affected tests passed 14/14, and the shipped InstallAndroidDependencies target, run with the real Android CLI against an empty SDK directory and $(AndroidSdkPlatformToolsVersion)=37.0.1, installed [email protected] (adb version reported 37.0.3-16887417). The full InstallAndroidDependenciesTest application cases were not run.

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

Version checks can accept a preview instead of a stable release or reject equivalent revisions, while CLI failure diagnostics omit potentially explanatory stdout.

3 open issues
1 file not reviewed
  • src/Xamarin.Installer.Build.Tasks/Properties/Resources.Designer.cs: Generated file
What changed in this PR

Builds on the platform-tools 37.0.3 update (#13666) by resolving installer versions from the live catalog, reducing reliance on exact point releases Google may remove. Repository provisioning pins remain unchanged.

Changes:

  • Selects the newest stable platform-tools release within the requested major band, respecting the minimum version.
  • Shares the package-list parser and adds roll-forward tests, including Windows fake-CLI handling.
  • Adds XA5309–XA5311 diagnostics and documents version-selection behavior and archive trust.
File Description
src/​Xamarin.Installer.Build.Tasks/​Xamarin.Installer.Common.props Adds a comment distinguishing installer roll-forward from workload revisions.
src/​Xamarin.Installer.Build.Tasks/​Xamarin.Installer.Build.Tasks.csproj Links the shared package-list parser source.
src/​Xamarin.Installer.Build.Tasks/​Tasks/​InstallAndroidDependencies.cs Adds catalog resolution, version validation, and installation filtering.
src/​Xamarin.Installer.Build.Tasks/​Properties/​Resources.resx Defines three new installer error messages.
src/​Xamarin.Installer.Build.Tasks/​Properties/​Resources.Designer.cs Exposes accessors for the new messages.
src/​Xamarin.Android.Tools.AndroidSdk/​SdkPackageListParser.cs Extracts existing package-list parsing into a shared helper.
src/​Xamarin.Android.Tools.AndroidSdk/​SdkManager.Packages.cs Delegates parsing to the shared helper.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​AndroidDependenciesTests.cs Tests selection, installed versions, failures, and cross-platform CLI invocation.
Documentation/​docs-mobile/​TOC.yml Adds navigation entries for the new errors.
Documentation/​docs-mobile/​messages/​xa5311.md Documents invalid version requests.
Documentation/​docs-mobile/​messages/​xa5310.md Documents missing compatible catalog versions.
Documentation/​docs-mobile/​messages/​xa5309.md Documents catalog-command failures.
Documentation/​docs-mobile/​messages/​index.md Indexes the three new errors.
Documentation/​docs-mobile/​building-apps/​build-targets.md Explains roll-forward rules, overrides, and archive verification.

Review effort: Balanced

Base automatically changed from simonrozsival-update-platform-tools-37-0-3 to main November 20, 2026 21:28
jonathanpeppers and others added 3 commits November 20, 2026 15:28
cmd.exe splits --sdk=PATH at '=', so %4 was not 'list' on Windows and
the catalog query went to the install branch. Search for a 'list'
token instead of a fixed argument position.

Co-authored-by: Copilot App <[email protected]>
…allation

A stale args.txt from an earlier run made the test fail.

Co-authored-by: Copilot App <[email protected]>
jonathanpeppers added a commit that referenced this pull request Nov 20, 2026
Context: #13646, #13644

`InstallAndroidDependenciesTest` fails on `main` because Google removed platform-tools 37.0.1 from its SDK catalog. Android CLI 1.1.16717390 returns success for `[email protected]` but logs `No url for platform-tools. Ignoring.`, so platform-tools is not installed.

Update platform-tools to 37.0.3, which is in the current catalog:

  * `$(XAPlatformToolsVersion)` and the macOS, Linux, and Windows SHA-256 hashes in `Configuration.props`.
  * The shipped `$(AndroidSdkPlatformToolsVersion)` default used by the `InstallAndroidDependencies` target.
  * A 37.0.3 entry in `AndroidManifestFeed_d18.0.xml`. Without it, `WorkloadDependencies.json` falls back to the newest feed revision, 37.0.1. Sizes and SHA-1 checksums come from https://dl.google.com/android/repository/repository2-3.xml.

Google can remove 37.0.3 later in the same way. #13691 changes `<InstallAndroidDependencies/>` to roll forward to the newest stable platform-tools in the same major version.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Jonathan Peppers <[email protected]>
@jonathanpeppers
jonathanpeppers force-pushed the jonathanpeppers-platform-tools-roll-forward branch from af9b1de to de79880 Compare November 20, 2026 21:28
@simonrozsival

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13691

@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

Reviewed all 14 changed files at de7988020ec86a4d167390ef1f7a36525c4e3133, including the full files, dependency-generation caller, process helper, project configuration, and existing parser tests. The same-major selection, numeric ordering, preview filtering of catalog candidates, unversioned behavior, and XA5309–XA5311 documentation are coherent. Sharing the existing parser preserves its behavior without expanding the public API, and the Windows fake-CLI correction addresses the argument-position problem described in the PR.

Findings: 0 errors, 2 warnings already covered by existing inline threads, and 1 new suggestion. The existing stdout diagnostic warning and four-component minimum warning still apply to this head: XA5309 receives only stderr, and the accepted minimum 37.0.3.0 does not match catalog revision 37.0.3 under System.Version comparison. I have not duplicated those comments. The new test-coverage suggestion is posted inline.

CI: All 38 GitHub check runs report completed/success, including the aggregate dotnet-android check for build 1692952. Direct Azure DevOps build/timeline verification was unavailable: the build query required authentication and the timeline command failed before returning data. Consequently, I cannot independently certify the Azure build result. Local tests were not run during this review.

The PR also documents a merge dependency on #13666.

Generated by Android PR Reviewer for #13691 · copilot · gpt61 · 40.2 AIC · ⌖ 7.96 AIC · ⊞ 20.3K
Comment /review to run again

* XA5309 now includes the end of the Android CLI standard output, not
  only standard error.
* An installed platform-tools preview, such as 37.0.3-rc1, no longer
  satisfies the stable release with the same number.
* Test that AcceptAndroidSDKLicenses=false succeeds when the selected
  version is installed, and fails before installation for an upgrade.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13691

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

Code assessment: no blocking findings — 0 errors, 0 warnings, 1 non-blocking testing suggestion inline.

Reviewed all 14 changed files in full and traced dependency generation and package-list parsing. The major-band selection, numeric ordering, malformed-version diagnostics, and unchanged handling of other package types are consistent with the stated behavior. The previous stdout-diagnostic, equal-numbered-preview, and license-check findings now have corresponding fixes and regression coverage. The parser extraction preserves the existing parsing algorithm without expanding the public API.

CI: All 38 GitHub checks report success, including the aggregate dotnet-android check for Azure build 1695430. Independent Azure build/timeline verification was blocked because az devops invoke requires authentication in this environment, so that portion of CI verification remains incomplete. No local builds or tests were run for this review.

Generated by Android PR Reviewer for #13691 · copilot · gpt61 · 39.2 AIC · ⌖ 7.82 AIC · ⊞ 20.3K
Comment /review to run again

[TestCase ("37.0", "37.0.3", "37.0.3", null, null, TestName = "PlatformToolsLatestAlreadyInstalled")]
[TestCase ("37.0", "37.0.1", "37.0.3", "[email protected]", null, TestName = "PlatformToolsRollsForwardWithinMajor")]
[TestCase ("37.0", "38.0.0", "37.0.3", null, null, TestName = "PlatformToolsNewerMajorInstalled")]
[TestCase ("37.0", "37.0.3-rc1", "37.0.3", "[email protected]", null, TestName = "PlatformToolsPreviewInstalled")]

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 — Consider adding the complementary case with 37.0.4-rc1 installed and 37.0.3 available, expecting no installation. The existing case protects replacement of an equal-numbered preview, but not the intentional distinction that a numerically newer preview is left alone. That extra row would protect the equality-only preview guard in IsInstalled from accidentally becoming a blanket rejection of installed previews.

{Rule: Test edge cases and preserve existing behavior}

This branch has not been deployed

No deployments
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