Repository navigation
[Microsoft.Android.Build.Tasks] Move InstallAndroidDependencies into MABT - #13520
simonrozsival wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A trailing separator in a valid JdkPath places staging inside the JDK directory, causing RemoveJdk() to delete both the existing JDK and newly extracted files before the move.
1 open issue
1 file not reviewed
src/Xamarin.Installer.AndroidSDK/Properties/Resources.Designer.cs: Generated file
What changed in this PR
This PR improves process and resource ownership in the legacy Android SDK installer, addressing the process-lifetime audit tracked in #12981.
Changes:
- Replaces license busy-polling with prompt-driven answers, cancellable input, concurrent output capture, and bounded cleanup.
- Moves Java extraction to native process capture with structured arguments, a deadline, diagnostics, and staging cleanup.
- Removes unused command helpers and adds standalone regression coverage.
| File | Description |
|---|---|
tests/Xamarin.Android.Tools.AndroidSdk-Tests/AndroidSdkInstallerTests.cs |
Adds license lifecycle and Java extraction regression tests. |
src/Xamarin.Installer.Common/Xamarin.Installer.Common/CommonUtilities.cs |
Removes unused RunCommand overloads. |
src/Xamarin.Installer.AndroidSDK/Xamarin.Installer.AndroidSDK/JavaDependencyInstaller.cs |
Adds bounded extraction, layout checks, and staging cleanup. |
src/Xamarin.Installer.AndroidSDK/Xamarin.Installer.AndroidSDK/Common/AndroidLicensesStorage.cs |
Owns license process input, output, cancellation, and log lifetimes. |
src/Xamarin.Installer.AndroidSDK/Properties/Resources.resx |
Adds localized timeout and extraction error messages. |
src/Xamarin.Installer.AndroidSDK/Properties/Resources.Designer.cs |
Exposes the new resource strings. |
.github/skills/tests/references/test-catalog.md |
Documents the focused installer test command. |
Review effort: Balanced
d4f9f1c to
a235b37
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
⚠️ Needs Changes
Findings: 1 ❌ error, 0 JdkPath, and committing an otherwise valid archive deletes both the installed JDK and its replacement. The inline comment describes the normalization and regression coverage needed.
The license changes improve ownership substantially: prompt-driven selective answers replace busy polling, stdout/stderr are consumed concurrently, sink access is synchronized, and process-exit/output-EOF handling has explicit deadlines. The new fixtures cover cancellation, blocked stdin, late diagnostics, sink failures, and repeated native-capture reader disposal. I reviewed all seven changed files, the affected callers, and the project target frameworks against the stacked PR diff.
CI: All 40 returned GitHub checks are completed/successful, including the aggregate dotnet-android check for build 1677892. Independent Azure build/timeline verification was blocked by Azure CLI initialization/authentication errors, so that verification remains incomplete.
Local validation: dotnet test tests/Xamarin.Android.Tools.AndroidSdk-Tests/Xamarin.Android.Tools.AndroidSdk-Tests.csproj -v minimal --filter FullyQualifiedName~AndroidSdkInstallerTests could not start: .NET CLI initialization failed creating the NuGet-Migrations mutex because its runtime directory was unavailable. No tests executed locally; the installed SDK also reports 10.0.403 while these projects target net11.0.
Generated by Android PR Reviewer for #13520 · copilot · gpt61 · 32.3 AIC · ⌖ 4.72 AIC · ⊞ 20.2K
Comment /review to run again
b4ba1ba to
7d5da70
Compare
7d5da70 to
c545363
Compare
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
⚠️ Validation incomplete — no blocking code findings
Reviewed all 15 changed files, including the full moved implementations, project/packaging wiring, task registrations, and test coverage. Findings: 0 errors, 0 warnings, 2 non-blocking suggestions, posted inline for deterministic extraction and process-lifecycle coverage.
The migration keeps signature/hash verification intact, resolves project-relative installation paths through TaskEnvironment, uses structured process arguments, and preserves calling-thread logging. Linking the installer resources into MABT and retaining the shipped props/targets is consistent with the surrounding migration pattern.
CI: All 40 GitHub checks for head 07c58d96 report success, including the aggregate dotnet-android check and Windows/Linux/macOS lanes. I could not independently verify Azure build 1679429: the Azure CLI required authentication and the direct public REST read was denied. Consequently, this is not an unconditional CI-green/LGTM verdict.
Local validation: Attempted dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --filter 'FullyQualifiedName~InstallAndroidDependenciesTests|FullyQualifiedName~OpenJdkSignatureTests' -v minimal; the .NET CLI failed during NuGet first-use initialization before building or executing tests. No local test pass is claimed. The worktree was left unchanged.
Generated by Android PR Reviewer for #13520 · copilot · gpt61 · 48.3 AIC · ⌖ 7.51 AIC · ⊞ 19.5K
Comment /review to run again
There was a problem hiding this comment.
⚠️ Validation incomplete — no blocking code findings
Reviewed all 15 changed files, including the full moved implementations, project/packaging wiring, task registrations, and test coverage. Findings: 0 errors, 0 warnings, 2 non-blocking suggestions, posted inline for deterministic extraction and process-lifecycle coverage.
The migration keeps signature/hash verification intact, resolves project-relative installation paths through TaskEnvironment, uses structured process arguments, and preserves calling-thread logging. Linking the installer resources into MABT and retaining the shipped props/targets is consistent with the surrounding migration pattern.
CI: All 40 GitHub checks for head 07c58d96 report success, including the aggregate dotnet-android check and Windows/Linux/macOS lanes. I could not independently verify Azure build 1679429: the Azure CLI required authentication and the direct public REST read was denied. Consequently, this is not an unconditional CI-green/LGTM verdict.
Local validation: Attempted dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --filter 'FullyQualifiedName~InstallAndroidDependenciesTests|FullyQualifiedName~OpenJdkSignatureTests' -v minimal; the .NET CLI failed during NuGet first-use initialization before building or executing tests. No local test pass is claimed. The worktree was left unchanged.
Generated by Android PR Reviewer for #13520 · copilot · gpt61 · 48.3 AIC · ⌖ 7.51 AIC · ⊞ 19.5K
Comment /review to run again
…MABT Context: #12981 Context: https://devblogs.microsoft.com/dotnet/process-api-improvements-in-dotnet-11/ Context: https://learn.microsoft.com/visualstudio/msbuild/update-task-multithreaded After #13513, `InstallAndroidDependencies` installs SDK packages with Google's Android CLI, but it still lived in the netstandard2.0 `Xamarin.Installer.Build.Tasks.dll`. There it had to start the Android CLI, `/usr/bin/tar`, and `chmod` through `ProcessUtils`, and it could not run in multithreaded MSBuild (`-mt`). Move the task, `JavaDependencyInstaller`, and `OpenJdkSignatureVerifier` into `Microsoft.Android.Build.Tasks.dll`, which runs on .NET: * Register the task with the paired Full/Core `Runtime="NET"` `<UsingTask/>`. MABT links the existing localized messages and deploys `Xamarin.Installer.Common.props` and `.targets` to `tools`, so `Xamarin.Android.Common.targets` and the localization files are unchanged. Remove `Xamarin.Installer.Build.Tasks.csproj`. * Run the Android CLI with `Process.ReadAllLinesAsync()` and `WaitForExitAsync()`, keeping only the tail of its output as before, and kill its process tree when the task fails or is canceled. Extract JDK `.tar.gz` archives with `TarFile`, and mark the downloaded Android CLI executable with `File.SetUnixFileMode()`. * Derive from `MultithreadedAndroidTask` with `[MSBuildMultiThreadableTask]` and `ICancelableTask`. `RunTask()` runs the existing async workflow on the thread pool and forwards log messages to the thread that called `Execute()`, as `AsyncTask` did. Environment variables, the child process start info, and all paths come from `TaskEnvironment`; resolved paths are passed around as `AbsolutePath`. The default SDK and JDK locations come from the task's `LOCALAPPDATA` or `HOME`. Three analyzer findings are suppressed with justifications: `Process.Start()` (its `ProcessStartInfo` comes from `TaskEnvironment.GetProcessStartInfo()`), `Path.GetTempFileName()` (no `TaskEnvironment` alternative yet), and `Environment.GetFolderPath(ProgramFiles)` (a machine location). `OpenJdkSignatureTests` and the unit tests that create the task move to the net12.0 `Microsoft.Android.Build.Tasks.Tests`. The fake Android CLI test now also checks that a relative `AndroidSdkPath` resolves against the project directory and that messages are logged on the `Execute()` thread. Co-authored-by: Copilot App <[email protected]>
…ependenciesTests Co-authored-by: Copilot App <[email protected]>
07c58d9 to
209dbea
Compare
Remove the custom logging queue: TaskLoggingHelper supports logging from any thread, and this .NET-only task runs out of process when hosted by full-framework MSBuild. Pair Yield/Reacquire around the async workflow. Keep Process.ReadAllLinesAsync to drain both streams while retaining only 4096 characters, instead of capturing unbounded CLI progress. Replace the locked TextWriter with a local StringBuilder and wait for the CLI after cancellation kills it. Keep the moved installer unit tests and add offline coverage for cancellation after startup, XA5308 output tails, executable permissions, relative symlinks, replacement, staging cleanup, and trailing directory separators. Validation on macOS: standalone task/test build passed without warnings; 62 focused installer/signature tests passed; ordinary and strict -m -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288 task execution passed using /usr/bin/true as the CLI (expected missing-package warnings). Windows and Linux were not run. Co-authored-by: Copilot App <[email protected]>
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
✅ LGTM — code review
0 errors · 0 warnings · 1 non-blocking suggestion, posted inline.
Reviewed all 15 changed files in full, the task's base-class behavior, callers/registrations, resource wiring, and packaging changes at 1ef0ba822696a83046332e5065d174e071b7779e. No blocking correctness issues found. The offline extraction tests now cover executable permissions, relative symlinks, replacement, staging cleanup, and trailing separators; the CLI tests cover cancellation after readiness and failure-output retention. These address the earlier review suggestions without repeating them here.
CI: All 38 GitHub checks report success, including the aggregate dotnet-android check for Azure build 1694617. Direct Azure build/timeline verification was blocked because az devops invoke requires authentication in this environment, so that result was not independently confirmed through Azure. Local tests were not rerun; the installed SDKs stop at .NET 11, while the moved test project targets .NET 12.
Generated by Android PR Reviewer for #13520 · copilot · gpt61 · 45.6 AIC · ⌖ 4.44 AIC · ⊞ 21K
Comment /review to run again
| var task = new InstallAndroidDependencies { | ||
| BuildEngine = new MockBuildEngine (TestContext.Out, errors, [], []), | ||
| // Relative paths resolve against the project directory, not the process working directory. | ||
| TaskEnvironment = TaskEnvironment.CreateWithProjectDirectoryAndEnvironment (root, new Dictionary<string, string> ()), |
There was a problem hiding this comment.
🤖 💡 Testing — Consider supplying a unique test-only environment variable here and having the fake CLI write its value to a file for assertion. The relative paths already exercise project-relative path resolution, but the empty environment means this test would still pass if process creation accidentally inherited the node's environment instead of the task's. An explicit value would protect the environment-isolation part of this multithreaded migration without changing the parent process environment.
{Rule: Test project-specific environment isolation}

Context: #12981
Context: https://devblogs.microsoft.com/dotnet/process-api-improvements-in-dotnet-11/
Context: https://learn.microsoft.com/visualstudio/msbuild/update-task-multithreaded
After #13513,
InstallAndroidDependenciesuses Google's Android CLI but still lives in the netstandard2.0 installer task assembly. Move it,JavaDependencyInstaller, andOpenJdkSignatureVerifierinto the net12.0Microsoft.Android.Build.Tasks.dll, enabling modern .NET APIs and multithreaded MSBuild. Remove the old installer project while retaining its localized resources and shipped props/targets./usr/bin/tarwithGZipStreamandTarFile.ExtractToDirectoryAsync(), andchmodwithFile.SetUnixFileMode().Process.ReadAllLinesAsync()to drain stdout and stderr together, retaining only the last 4,096 characters forXA5308.RunAndCaptureTextAsync()would retain all progress output. Cancellation kills the CLI's process tree and waits for the CLI to exit.MultithreadedAndroidTask, declare[MSBuildMultiThreadableTask], and useTaskEnvironmentfor project paths, environment variables, and child process configuration. PairYield()/Reacquire()around the async workflow. Use the thread-safeTaskLoggingHelperdirectly instead of recreatingAsyncTask's legacy log-forwarding queues; full-framework MSBuild hosts this .NET-only task out of process.Runtime="NET"registration, usingTaskHostFactoryonly for Full MSBuild. Retain justified analyzer suppressions forProcess.Start()with task-supplied start info, scratch-file creation, and machine-wide Program Files discovery.InstallAndroidDependenciesTestsmoves the existing fake-CLI and invalid-JDK tests out ofXamarin.Android.Build.Tests;OpenJdkSignatureTestsalso moves to the net12.0 test project. Extend the moved coverage with cancellation after child readiness, nonzero exits and output tails, and offline tar.gz extraction checking executable permissions, relative symlinks, replacement, staging cleanup, and trailing directory separators. The four unresolved review threads were two duplicated suggestions for this coverage.The follow-up removes 91 lines from the task compared with the initial migration; the task is now only 15 lines longer than before the move.
Validation for
1ef0ba8226on macOS arm64:dotnet build build-tools/xa-prep-tasks/xa-prep-tasks.csproj --nologo -v:q: passed, 0 warnings/errors (required build prerequisite in this fresh worktree).dotnet build src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --nologo -v:q: passed, 0 warnings/errors.dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj --no-build --filter 'FullyQualifiedName~InstallAndroidDependenciesTests|FullyQualifiedName~OpenJdkSignatureTests' --nologo -v:minimal: passed 62/62./usr/bin/trueas the CLI passed ordinary execution and strict-m -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288execution. Both emitted the expected warning that the stub did not install the requested package; no real SDK packages were downloaded.Full SDK/device tests and Windows/Linux execution were not rerun for this follow-up. Earlier full-SDK and integration results applied to an earlier revision, not this head.