Repository navigation
[Xamarin.Android.Tools] Quote sdkmanager package IDs - #13621
Merged
Merged
Conversation
Windows Command-line Tools 23 can split semicolon-delimited package IDs when sdkmanager.bat is launched with ProcessStartInfo.ArgumentList. The batch shim then exits successfully without installing the requested package. Invoke the batch launcher through the system cmd.exe, validate package IDs, and explicitly quote each argument at the cmd.exe boundary. Cover the behavior through SdkManager.InstallAsync(). Co-authored-by: Copilot App <[email protected]>
rmarinho
requested review from
jonathanpeppers and
simonrozsival
as code owners
November 18, 2026 14:24
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new package-ID validation lacks tests confirming that InstallAsync and UninstallAsync reject invalid inputs before SDK lookup or process launch while accepting valid slash-separated IDs.
1 open issue
What changed in this PR
Addresses #13617 in the shared Android SDK tooling by preserving semicolon-delimited package IDs when launching Windows sdkmanager.bat, avoiding successful exits without installing the requested packages.
Changes:
- Launches Windows batch shims through system
cmd.exe, with explicit argument quoting and delayed expansion disabled. - Validates package IDs before installation or removal.
- Adds a Windows regression test verifying that a complete package ID reaches a stub batch launcher.
| File | Description |
|---|---|
tests/Xamarin.Android.Tools.AndroidSdk-Tests/SdkManagerTests.cs |
Adds a batch-launch regression test for semicolon-delimited IDs. |
src/Xamarin.Android.Tools.AndroidSdk/SdkManager.Process.cs |
Adds explicit Windows batch launching and argument quoting. |
src/Xamarin.Android.Tools.AndroidSdk/SdkManager.Packages.cs |
Rejects empty or unsupported package IDs before execution. |
Review effort: Balanced
Verify that unsafe package IDs are rejected before SDK lookup and that both semicolon- and slash-separated package IDs reach the Windows batch launcher unchanged. Co-authored-by: Copilot App <[email protected]>
jonathanpeppers
left a comment
Member
There was a problem hiding this comment.
🤖 Review: the fix is correct. These comments are about how to make it simpler.
Remove the unreachable non-batch launcher path and redundant package validation cases. Keep the SDK path in an environment variable so cmd.exe does not expand metacharacters within it. Co-authored-by: Copilot App <[email protected]>
jonathanpeppers
approved these changes
Nov 18, 2026
Member
|
/backport to release/11.0.1xx |
Contributor
|
Started backporting to |
jonathanpeppers
pushed a commit
that referenced
this pull request
Nov 19, 2026
Fixes: #13617 Windows Command-line Tools 23 can split semicolon-delimited package IDs such as `build-tools;37.0.0` when `sdkmanager.bat` is launched with `ProcessStartInfo.ArgumentList`. The batch shim then exits successfully without installing the requested package. Launch Windows batch shims through the system `cmd.exe` with delayed expansion disabled, validate package IDs, and explicitly quote each argument at the `cmd.exe` boundary. The regression test invokes `SdkManager.InstallAsync()` against a stub batch launcher and verifies that a semicolon-delimited package ID arrives as one argument. Focused validation tests also verify that unsafe package IDs are rejected before SDK lookup. Co-authored-by: Rui Marinho <[email protected]> Co-authored-by: Copilot App <[email protected]>
simonrozsival
added a commit
that referenced
this pull request
Nov 21, 2026
The rebase onto cc7cbf6 kept the pre-rebase MSTest conversions of files that main had changed since aa688ac, which reverted those changes and broke the build. For each affected file, convert main's old and new NUnit versions with the same converter and merge the difference into the MSTest file: * cca255c (#13592): drop the Android lint tests and assertions. * 5b32fb1 (#13602): add RelativeDirectoriesUseProjectDirectory and the -mt CollectNonEmptyDirectories coverage. * 78ef747 (#13655): add OpenGenericProxiesKeepTheReflectionActivationConstructor. * 18b8940 (#13585): add the generator nullability/obsolete tests. * dcbd008 (#13580): add the AmbiguousFunctionMetadata_* tests. * 667e27a (#13621): add the sdkmanager package ID tests. * 5ecb8f7 (#13614): drop RunWithLoggingEnablesManagedTimingLogger. * 8287b17 (#13680), 4bfcc92 (#13681): restore the re-enabled tests and removed TODOs. * 5d81a0f (#13666): expect platform-tools 37.0.3. * 8442c75 (#13601): assert the pulled device TRX is deleted. Also drop the EnableNUnitRunner/OutputType lines that 857f463 (#13563) added to Xamarin.Android.Build.Tests and MSBuildDeviceIntegration; MSTestReferences.projitems sets both. Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes: #13617
Windows Command-line Tools 23 can split semicolon-delimited package IDs such as
build-tools;37.0.0whensdkmanager.batis launched withProcessStartInfo.ArgumentList. The batch shim then exits successfully without installing the requested package.Launch Windows batch shims through the system
cmd.exewith delayed expansion disabled, validate package IDs, and explicitly quote each argument at thecmd.exeboundary. The regression test invokesSdkManager.InstallAsync()against a stub batch launcher and verifies that a semicolon-delimited package ID arrives as one argument. Focused validation tests also verify that unsafe package IDs are rejected before SDK lookup.Validation
dotnet build src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj -v:minimal— passed with 0 warnings and 0 errors.dotnet test tests\Xamarin.Android.Tools.AndroidSdk-Tests\Xamarin.Android.Tools.AndroidSdk-Tests.csproj -v:minimal --filter "Name~InstallAsync_InvalidPackageId_ThrowsBeforeSdkLookup|Name~InstallAsync_WindowsBatch_PreservesPackageId"— passed 3 tests.dotnet test tests\Xamarin.Android.Tools.AndroidSdk-Tests\Xamarin.Android.Tools.AndroidSdk-Tests.csproj -v:minimal --filter "Name!~CreateProcessStartInfo_"— passed 413 tests; 39 platform-specific tests skipped.The unfiltered project run has three pre-existing
CreateProcessStartInfo_*failures because thenetstandard2.0library build usesProcessStartInfo.Argumentswhile those tests assertArgumentList.