[cli] implement dotnet maui screenshot command#33551
Closed
jonathanpeppers wants to merge 8 commits intomainfrom
Closed
[cli] implement dotnet maui screenshot command#33551jonathanpeppers wants to merge 8 commits intomainfrom
dotnet maui screenshot command#33551jonathanpeppers wants to merge 8 commits intomainfrom
Conversation
Adds a new CLI tool for .NET MAUI that captures screenshots from
connected devices and emulators.
Key additions:
* CLI infrastructure with `Program.cs` and `CommonOptions.cs` (shared
options like --device)
* `ScreenshotCommand` for capturing screenshots from Android, iOS,
Windows, and macOS.
* `NativeMethods` for platform-specific interop operations
* Unit tests for root command, screenshot command, and platform
detection
The CLI is packaged as a dotnet tool (`Microsoft.Maui.Cli`) and uses
dotnet/arcade's `$(SuppressFinalPackageVersion)` to remain in preview
when the rest of MAUI ships as stable.
Some examples:
# Basic screenshot from your desktop OS
dotnet maui screenshot
# Screenshot from default Android/adb connection
dotnet maui screenshot --framework net10.0-android
# Screenshot from a specific Android emulator
dotnet maui screenshot --framework net10.0-android --device emulator-5554
# Screenshot with a custom output filename
dotnet maui screenshot --output ./screenshots/home-screen.png
# Wait 3 seconds before capturing (for animations to complete)
dotnet maui screenshot -f net10.0-android -w 3 -o after-animation.png
# Verbose output for debugging
dotnet maui screenshot -f net10.0-android --verbose
# Get help
dotnet maui screenshot --help
dotnet maui --help
TODO:
* Prompt for OS / device if unspecified. Similar to `dotnet run`.
* `--list-devices` global option
* iOS physical device screenshots
* Use of .NET MAUI project in current directory.
* Add more subcommands! `dotnet maui log/logs`, `dotnet maui tree`,
etc.
54 tasks
Member
Author
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new dotnet maui screenshot CLI tool for capturing screenshots from Android, iOS, Windows, and macOS devices/emulators. The implementation includes complete CLI infrastructure with command parsing, platform-specific screenshot capture methods, and comprehensive unit tests.
Changes:
- Added new CLI tool project (
Microsoft.Maui.Cli) packaged as a dotnet tool with preview versioning - Implemented screenshot command with support for Android (adb), iOS Simulator (xcrun simctl), Mac Catalyst (screencapture), and Windows (Win32 APIs)
- Added unit tests covering CLI commands, options, and platform detection logic
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Cli/src/Cli/Program.cs | Entry point and root command setup |
| src/Cli/src/Cli/CommonOptions.cs | Global CLI options (framework, device, project, verbose) |
| src/Cli/src/Cli/Commands/Screenshot/ScreenshotCommand.cs | Screenshot command implementation with platform-specific handlers |
| src/Cli/src/Cli/NativeMethods.cs | Windows P/Invoke declarations for screen capture |
| src/Cli/src/Cli/Cli.csproj | CLI tool project configuration with preview versioning |
| src/Cli/tests/Cli.UnitTests/Cli.UnitTests.csproj | Unit test project configuration |
| src/Cli/tests/Cli.UnitTests/CliTestHelper.cs | Test helper for CLI command execution |
| src/Cli/tests/Cli.UnitTests/RootCommandTests.cs | Tests for root command help and validation |
| src/Cli/tests/Cli.UnitTests/Commands/Screenshot/ScreenshotCommandTests.cs | Tests for screenshot command options and execution |
| src/Cli/tests/Cli.UnitTests/Commands/Screenshot/GetTargetPlatformIdentifierTests.cs | Tests for platform detection from TFM strings |
| eng/pipelines/arcade/stage-unit-tests.yml | CI pipeline integration for unit tests |
| eng/Versions.props | Added Xamarin.Android.Tools.AndroidSdk package version |
| eng/Version.Details.xml | Added dependency details for Android SDK tools |
| NuGet.config | Added package source for dotnet-android dependencies |
| Microsoft.Maui.sln | Added CLI projects to main solution |
| Microsoft.Maui-vscode.sln | Added CLI projects to VS Code solution |
| Microsoft.Maui-dev.sln | Added CLI projects to dev solution |
Member
Author
|
/azp run maui-pr-uitests maui-pr-devicetests |
|
No pipelines are associated with this pull request. |
Member
Author
|
/azp run maui-pr-devicetests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
3 tasks
Member
Author
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Jan 16, 2026
jfversluis
previously approved these changes
Jan 16, 2026
rolfbjarne
requested changes
Jan 16, 2026
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Updated CreateProcessStartInfo to accept params string[] and populate ArgumentList, avoiding quoting issues with command arguments.
rolfbjarne
approved these changes
Jan 19, 2026
Member
Author
|
This is here now: https://github.com/dotnet/maui-labs |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Spec: https://github.com/dotnet/maui/blob/5ecf21af9f043b74906abc8b5ae16368e9fa628b/docs/design/cli.md
Adds a new CLI tool for .NET MAUI that captures screenshots from
connected devices and emulators.
Key additions:
CLI infrastructure with
Program.csandCommonOptions.cs(sharedoptions like
--deviceand--framework)ScreenshotCommandfor capturing screenshots from Android, iOS,Windows, and macOS.
NativeMethodsfor Windows interopUnit tests for root command, screenshot command, and platform
detection
The CLI is packaged as a dotnet tool (
Microsoft.Maui.Cli) and usesdotnet/arcade's
$(SuppressFinalPackageVersion)to remain in previewwhen the rest of MAUI ships as stable.
Some examples:
TODO:
Prompt for OS / device if unspecified. Similar to
dotnet run.--list-devicesglobal optioniOS physical device screenshots
Use of .NET MAUI project in current directory.
Add more subcommands!
dotnet maui log/logs,dotnet maui tree,etc.