Skip to content

[android-tools] Align command-line tool discovery order - #12319

Open
jonathanpeppers wants to merge 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-align-sdk-discovery
Open

[android-tools] Align command-line tool discovery order#12319
jonathanpeppers wants to merge 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-align-sdk-discovery

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

FindSdkManagerPath() and FindCmdlineTool() must resolve Android command-line tools consistently. Prefer the SDK-managed cmdline-tools/latest/bin layout before considering versioned installations, while retaining versioned fallback when latest does not contain the requested binary.

The shared resolver now treats latest as the first selection tier. Remaining candidates continue to use Pkg.Revision, parsed directory versions, and deterministic fallback ordering. Legacy tools/bin remains intentionally unsupported because those tools use incompatible command-line arguments.

Tests cover lower or malformed metadata on latest, versioned fallback, and exclusion of legacy tools/bin. The full Xamarin.Android.Tools.AndroidSdk-Tests project passes with 378 passed and 16 skipped.

Fixes #12072

Prefer cmdline-tools/latest before versioned installations for both sdkmanager and other command-line tools, while retaining versioned fallback and excluding legacy tools/bin.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 19:43

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

Aligns Android SDK command-line tool discovery so FindSdkManagerPath() and FindCmdlineTool() resolve binaries consistently by preferring the SDK-recommended cmdline-tools/latest/bin layout first, with deterministic fallback to versioned installations when latest doesn’t contain the requested tool. This brings the shared resolver behavior and unit tests in line with the intended precedence rules and explicitly keeps legacy tools/bin unsupported.

Changes:

  • Update command-line tools candidate ordering to always prioritize the latest directory when it contains the requested binary.
  • Refresh/add unit tests to validate latest precedence (including malformed metadata), fallback when latest lacks the tool, and exclusion of legacy tools/bin.
  • Update XML documentation to reflect the latest-first behavior and lack of tools/bin support.

Reviewed changes

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

File Description
tests/Xamarin.Android.Tools.AndroidSdk-Tests/CommandLineToolsResolverTests.cs Updates/adds tests covering latest precedence, fallback behavior, and legacy tools/bin exclusion.
src/Xamarin.Android.Tools.AndroidSdk/SdkManager.CommandLineTools.cs Updates FindSdkManager() documentation to describe latest-first selection and no legacy support.
src/Xamarin.Android.Tools.AndroidSdk/ProcessUtils.cs Updates FindCmdlineTool() documentation to describe latest-first selection and no legacy support.
src/Xamarin.Android.Tools.AndroidSdk/CommandLineToolsResolver.cs Adjusts candidate comparison to treat latest as the highest-precedence selection tier.

Comment thread src/Xamarin.Android.Tools.AndroidSdk/SdkManager.CommandLineTools.cs
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.

Align FindSdkManagerPath with FindCmdlineTool discovery order

2 participants