Skip to content

Add Microsoft.Maui.Client CLI tool#24

Merged
rmarinho merged 7 commits intomainfrom
feature/maui-client-tool
Mar 30, 2026
Merged

Add Microsoft.Maui.Client CLI tool#24
rmarinho merged 7 commits intomainfrom
feature/maui-client-tool

Conversation

@rmarinho
Copy link
Copy Markdown
Member

Summary

Move the maui CLI tool from dotnet/maui PR #34498 into maui-labs as a separate project alongside the existing maui-devflow CLI.

Two CLIs, One Repo

Tool Command Purpose
Microsoft.Maui.Client maui Environment setup — Android SDK, JDK, devices, doctor
Microsoft.Maui.DevFlow.CLI maui-devflow Runtime automation — visual tree, screenshots, CDP, MCP

What's Included

  • 29 source files in src/DevFlow/Microsoft.Maui.Client/ (~3.5K LOC)
  • 11 test files in src/DevFlow/Microsoft.Maui.Client.UnitTests/ (118 tests, all passing)
  • Commands: android sdk check/install, android jdk check/install, android emulator list/start/create, doctor, device list, version
  • DI-based architecture with interfaces, service pattern, separate command files

Build System Adaptation

  • Arcade SDK versioning replaces manual 0.0.1-alpha.{commit} scheme
  • Central package management via Directory.Packages.props
  • System.CommandLine 2.0.5 stable as central default; DevFlow keeps beta4 via VersionOverride
  • Spectre.Console 0.54.0 (upgraded from 0.49.1 to match repo standard — no code changes needed)
  • TFM: net10.0 (explicit, matching other DevFlow projects)

Dependencies Added

  • Xamarin.Android.Tools.AndroidSdk 1.0.143-preview.8 (android-tools NuGet)
  • Microsoft.Extensions.DependencyInjection 10.0.5
  • dotnet11 NuGet feed in NuGet.config
  • eng/Version.Details.xml darc entry for android-tools

Key Design Decisions

  1. Separate tools, not merged — different concerns, different release cadences
  2. System.CommandLine version split — central version is 2.0.5 stable; DevFlow overrides to beta4 (migration deferred to separate PR)
  3. PackAsTool=true with ToolCommandName=maui and IsShipping=true
  4. global.json updated to SDK 10.0.103 (locally available)

Test Results

Passed!  - Failed: 0, Passed: 118, Skipped: 0, Total: 118

Move the 'maui' CLI tool (Android SDK setup, JDK management, doctor,
devices) from dotnet/maui PR #34498 into maui-labs as a separate project
alongside the existing maui-devflow CLI.

- Add src/DevFlow/Microsoft.Maui.Client/ (29 source files)
- Add src/DevFlow/Microsoft.Maui.Client.UnitTests/ (11 test files)
- Adapt to Arcade SDK build system (versioning, central package mgmt)
- System.CommandLine 2.0.5 stable (central default); DevFlow keeps beta4 via VersionOverride
- Add Xamarin.Android.Tools.AndroidSdk 1.0.143-preview.8 dependency
- Add dotnet11 NuGet feed, Version.Details.xml darc entry
- 118 tests pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 14:09
rmarinho and others added 2 commits March 27, 2026 14:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new standalone .NET global tool, Microsoft.Maui.Client (maui), into maui-labs alongside the existing DevFlow CLI, focusing on environment setup (Android SDK/JDK/emulators), device listing, and a “doctor” readiness check.

Changes:

  • Adds the new src/DevFlow/Microsoft.Maui.Client/ CLI project with DI-based services, System.CommandLine commands, and Spectre.Console/JSON output.
  • Adds a dedicated unit test project Microsoft.Maui.Client.UnitTests covering core parsing, error modeling, and service wiring.
  • Updates repo build/dependency plumbing (central package versions, additional NuGet feed, solution/global.json updates) and keeps DevFlow CLI on System.CommandLine beta via VersionOverride.

Reviewed changes

Copilot reviewed 62 out of 66 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/DevFlow/Microsoft.Maui.DevFlow.CLI/Microsoft.Maui.DevFlow.CLI.csproj Keeps DevFlow CLI on System.CommandLine beta via VersionOverride.
src/DevFlow/Microsoft.Maui.Client/Microsoft.Maui.Client.csproj New maui tool project definition (PackAsTool, deps).
src/DevFlow/Microsoft.Maui.Client/Program.cs CLI entrypoint, DI bootstrap, global options, help handling.
src/DevFlow/Microsoft.Maui.Client/ServiceConfiguration.cs Registers core services/providers/output formatters.
src/DevFlow/Microsoft.Maui.Client/Utils/ProcessRunner.cs Process execution utility, elevation helpers, PATH lookup.
src/DevFlow/Microsoft.Maui.Client/Utils/PlatformDetector.cs OS/arch detection and common Android/JDK path discovery.
src/DevFlow/Microsoft.Maui.Client/Errors/MauiToolException.cs Structured exception type + remediation metadata.
src/DevFlow/Microsoft.Maui.Client/Errors/ErrorCodes.cs Error code taxonomy for tool/platform/user/network/permission.
src/DevFlow/Microsoft.Maui.Client/Models/Platforms.cs Platform constants + normalization/validation helpers.
src/DevFlow/Microsoft.Maui.Client/Models/ErrorResult.cs JSON-friendly structured error model and conversion from exceptions.
src/DevFlow/Microsoft.Maui.Client/Models/DoctorReport.cs Doctor report schema (checks/summary/status).
src/DevFlow/Microsoft.Maui.Client/Models/Device.cs Cross-platform device schema + legacy fields.
src/DevFlow/Microsoft.Maui.Client/Output/IOutputFormatter.cs Output abstraction for JSON vs rich console formatting.
src/DevFlow/Microsoft.Maui.Client/Output/JsonOutputFormatter.cs JSON output implementation (snake_case).
src/DevFlow/Microsoft.Maui.Client/Output/SpectreOutputFormatter.cs Spectre.Console output implementation (tables, spinners, progress).
src/DevFlow/Microsoft.Maui.Client/Output/SpectreHelpBuilder.cs Custom Spectre-based help rendering.
src/DevFlow/Microsoft.Maui.Client/Services/IDoctorService.cs Doctor service interface.
src/DevFlow/Microsoft.Maui.Client/Services/DoctorService.cs Doctor checks + autofix execution plumbing.
src/DevFlow/Microsoft.Maui.Client/Services/IDeviceManager.cs Device manager interface.
src/DevFlow/Microsoft.Maui.Client/Services/DeviceManager.cs Device aggregation/merging (ADB + AVD metadata).
src/DevFlow/Microsoft.Maui.Client/Providers/Android/IJdkManager.cs JDK management interface.
src/DevFlow/Microsoft.Maui.Client/Providers/Android/JdkManager.cs JDK detection + download/extract install implementation.
src/DevFlow/Microsoft.Maui.Client/Providers/Android/IAndroidProvider.cs Android provider API surface (devices, SDK, emulators, install).
src/DevFlow/Microsoft.Maui.Client/Providers/Android/AndroidProvider.cs Android provider implementation wiring SDK/JDK/ADB/AVD tooling.
src/DevFlow/Microsoft.Maui.Client/Providers/Android/SdkManager.cs Wrapper around android-tools SdkManager operations.
src/DevFlow/Microsoft.Maui.Client/Providers/Android/AvdManager.cs Wrapper around android-tools AVD/emulator runner operations.
src/DevFlow/Microsoft.Maui.Client/Providers/Android/Adb.cs Wrapper around android-tools ADB runner operations.
src/DevFlow/Microsoft.Maui.Client/Providers/Android/AndroidEnvironment.cs Android env var + ABI/API mapping helpers.
src/DevFlow/Microsoft.Maui.Client/Commands/CommandExtensions.cs Helper for retrieving command-local option values.
src/DevFlow/Microsoft.Maui.Client/Commands/VersionCommand.cs maui version command.
src/DevFlow/Microsoft.Maui.Client/Commands/DoctorCommand.cs maui doctor command (+ --fix, per-platform checks).
src/DevFlow/Microsoft.Maui.Client/Commands/DeviceCommand.cs maui device list command.
src/DevFlow/Microsoft.Maui.Client/Commands/AndroidCommands.cs maui android command group + shared helpers.
src/DevFlow/Microsoft.Maui.Client/Commands/AndroidCommands.Install.cs maui android install implementation (interactive/CI/progress).
src/DevFlow/Microsoft.Maui.Client/Commands/AndroidCommands.Jdk.cs maui android jdk commands.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-all.sh Demo runner script for multiple demos.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-overview.sh Demo: version/doctor/device list.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-json-scripting.sh Demo: --json scripting patterns.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-interactive-install.sh Demo: interactive Android install UX.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-android-sdk.sh Demo: Android SDK management flows.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-android-emulator.sh Demo: emulator management flows.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-apple.sh Demo script referencing Apple command group.
src/DevFlow/Microsoft.Maui.Client/Scripts/demo-simulator-boot.sh Demo script booting/shutting down Apple simulator via CLI.
src/DevFlow/Microsoft.Maui.Client.UnitTests/Microsoft.Maui.Client.UnitTests.csproj New unit test project definition.
src/DevFlow/Microsoft.Maui.Client.UnitTests/ServiceConfigurationTests.cs Tests DI registration and service override behavior.
src/DevFlow/Microsoft.Maui.Client.UnitTests/ProcessRunnerTests.cs Tests arg sanitization, ParseCommand, install path validation.
src/DevFlow/Microsoft.Maui.Client.UnitTests/PlatformsTests.cs Tests platform validation/normalization.
src/DevFlow/Microsoft.Maui.Client.UnitTests/OutputFormatterTests.cs Tests JSON + Spectre formatter behaviors.
src/DevFlow/Microsoft.Maui.Client.UnitTests/MauiToolExceptionTests.cs Tests exception/remediation metadata.
src/DevFlow/Microsoft.Maui.Client.UnitTests/ErrorCodesTests.cs Tests error code formatting/grouping assumptions.
src/DevFlow/Microsoft.Maui.Client.UnitTests/DoctorServiceTests.cs Tests doctor check aggregation/status behavior.
src/DevFlow/Microsoft.Maui.Client.UnitTests/DeviceManagerTests.cs Tests device aggregation/AVD merge behaviors.
src/DevFlow/Microsoft.Maui.Client.UnitTests/AndroidProviderTests.cs Tests Android provider-related behaviors via fakes.
src/DevFlow/Microsoft.Maui.Client.UnitTests/AndroidCommandsTests.cs Tests Android command shape and parsing behaviors.
src/DevFlow/Microsoft.Maui.Client.UnitTests/Fakes/FakeAndroidProvider.cs Test fake for IAndroidProvider with call tracking.
global.json Updates pinned SDK/tool versions.
eng/Versions.props Adds new version properties (DI, android-tools, cmdline stable pin).
eng/Version.Details.xml Adds darc dependency entry for android-tools package.
Directory.Packages.props Central package updates (System.CommandLine stable pin, new packages).
NuGet.config Adds a new package feed (dotnet11).
MauiLabs.sln Adds new Client + Client.UnitTests projects to solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

rmarinho and others added 3 commits March 27, 2026 14:28
The previous commit incorrectly renamed all 'DevFlow' solution folders
to 'Client'. Only the new folder for our projects should be 'Client'.

Also add .github/workflows/ci-client.yml for Client-specific CI that
runs build + 118 unit tests on macOS, Windows, and Ubuntu.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add src/Client/** to path triggers and build/test steps for
Microsoft.Maui.Client in the shared _build.yml workflow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Include Microsoft.Maui.Client and tests in the solution filter so
Arcade cibuild handles everything in one pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 64 out of 68 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Remove per-enum JsonConverter attributes (Device.cs, DoctorReport.cs)
  Global JsonOutputFormatter already configures snake_case converter
- Pass actual acceptLicenses parameter (AndroidProvider, AndroidCommands)
- Walk all ancestor commands for recursive options (SpectreHelpBuilder)
- Store and return resolved emulator path (AvdManager)
- Fix SdkManager doc comment (Error only, not Error/Warning)
- Add onProgress invocations in AcceptLicensesAsync (SdkManager)
- Skip option tokens in ResolveCommand (Program.cs)
- Add platform validation via Platforms.Normalize/IsValid (DeviceCommand)
- Replace naive Split with TokenizeArguments for quoted strings (DoctorService)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-Model Code Review

Three models (Opus, Sonnet, GPT) reviewed this PR in parallel with different focus areas.

Packaging & Release Readiness — All Clear

Every link in the release chain is correctly wired:

  • DevFlow.slnf includes both Microsoft.Maui.Client and its test project
  • devflow-official.yml builds that solution filter — built, tested, packed, signed in official builds
  • IsPackable=true, IsShipping=true, PackAsTool=true — Arcade produces a .nupkg
  • Signing covered by existing UseDotNetCertificate=true and Signing.props
  • Version management flows correctly through Arcade (Versions.props to Directory.Packages.props)
  • GitHub Actions CI updated with correct path triggers for src/Client/**
  • Version.Details.xml entry is well-formed, matches Versions.props

This tool will ship alongside DevFlow. No additional work needed.

Issues Found (for follow-up, not blocking)

Critical: Non-atomic directory operations in JDK installer
JdkManager.cs:319-330 — On macOS, the code does Move/Delete/Move to restructure the JDK Contents/Home directory. If any step fails mid-way, the JDK is lost with no rollback.

High: ProcessRunner.RunSync ignores its CancellationToken
The cancellationToken parameter is declared but never used. Ctrl+C will not interrupt long-running operations.

High: JDK download has no per-chunk read timeout
HttpClient.Timeout only covers the initial connection. A stalled mid-stream download can hang indefinitely.

High: Real provider/JDK paths are untested
The 118 tests cover fakes and service layer thoroughly, but AndroidProvider, JdkManager, and ProcessRunner.RunSync/RunAsync are never exercised with real implementations.

Medium: Doctor --fix pipeline untested
TryFixAsync, auto-fix sequencing, re-check after fix, and exit code logic are uncovered.

Medium: Emulator process handle leak on cancellation
AvdManager.cs:224-252 — If process.Kill() fails silently, the disposed handle leaves a zombie emulator.

What is Solid

  • DI architecture and service pattern — clean and well-structured
  • System.CommandLine version split — central stable 2.0.5, DevFlow keeps beta4 via VersionOverride
  • Test doubles (FakeAndroidProvider) — flexible, configurable, tracks calls
  • Test isolation and CI safety — no tests depend on external tools
  • Test naming — descriptive and scenario-oriented

Approving. The packaging story is complete, the architecture is sound, and the issues above are good follow-up items rather than blockers for a preview-stage product.

jfversluis added a commit that referenced this pull request Mar 29, 2026
- Remove Maui.Client references (PR #24 not yet merged to main)
- Fix MCP tool names and count: 49 actual tools, not 17
- Fix package count: 8 shipping packages, not 9
- Fix NuGet feeds: remove dotnet11 (not in NuGet.config)
- Fix CI commands: add --projects arg to match actual workflow
- Fix architecture diagram: broker uses WebSocket for agent
  registration, CLI talks directly to agent over HTTP
- Fix Websocket.Client dependency: belongs to CLI, not Agent.Core
- Fix agentPort convention: goes last, not second
- Fix Tool/Tools class naming: document both patterns
- Mark Maui.Client section as future/planned in copilot-instructions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rmarinho rmarinho merged commit 612adec into main Mar 30, 2026
3 checks passed
@rmarinho rmarinho deleted the feature/maui-client-tool branch March 30, 2026 11:07
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.

3 participants