Skip to content

Windows sdkmanager.bat splits semicolon-delimited package IDs with cmdline-tools 23 #13617

Closed

Description

@rmarinho

Description

On Windows, Xamarin.Android.Tools.AndroidSdk can report a successful SDK package installation even though sdkmanager.bat did not install the requested package. This affects semicolon-delimited package IDs such as build-tools;37.0.0 and platforms;android-37.0 with Android Command-line Tools 23.0.

This was found through dotnet/maui-labs#891. The MAUI CLI consumes Xamarin.Android.Tools.AndroidSdk and calls SdkManager.InstallAsync.

Reproduction

Use Windows x64 with:

  • Xamarin.Android.Tools.AndroidSdk 37.2.1-preview.14
  • Android Command-line Tools 23.0 under cmdline-tools\latest
  • JDK 21
  • A disposable Android SDK with accepted licenses but without the requested packages

Invoke the library's SdkManager.InstallAsync for:

platforms;android-37.0
build-tools;37.0.0

Equivalent CLI reproduction:

maui android sdk install --json 'platforms;android-37.0' 'build-tools;37.0.0'
maui android sdk list --json
Test-Path "$env:ANDROID_HOME\build-tools\37.0.0\aapt2.exe"
Test-Path "$env:ANDROID_HOME\platforms\android-37.0\android.jar"

Actual behavior

The install process exits with code 0, but neither package is installed. A direct unquoted invocation prints errors such as:

Package build-tools not found.
Package 37.0.0 not found.

The 23.0 Windows batch shim receives the portions around ; as separate arguments and still exits successfully.

Expected behavior

The complete package IDs reach sdkmanager.bat as individual quoted arguments, and the requested packages are installed. If installation fails, the operation should not report success.

Diagnosis

src/Xamarin.Android.Tools.AndroidSdk/SdkManager.Process.cs uses ProcessUtils.CreateProcessStartInfo(sdkManagerPath, arguments) on Windows. ProcessStartInfo.ArgumentList does not provide the required cmd.exe quoting boundary for this .bat launcher and Command-line Tools 23.0.

Passing the same package IDs with explicit quotes at the cmd.exe boundary installs both packages. Command-line Tools 19.0 also works with the existing invocation.

The MAUI CLI already has a working Windows-specific launcher pattern in Microsoft.Maui.Cli.Providers.Android.SdkManager.CreatePackageInstallStartInfo: it invokes cmd.exe /d /s /v:off /c, validates package IDs, and expands the quoted package through an environment variable. A comparable fix in Xamarin.Android.Tools.AndroidSdk would address all consumers.

Suggested coverage

Add a Windows process-start test verifying that a .bat sdkmanager receives build-tools;37.0.0 as one argument, plus an integration-style test using a stub batch file that records its arguments.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions