[MAUI] AddAndroidEmulator emits spurious 'run' arg; Microsoft.Android.Run rejects launch
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
## Summary
`Aspire.Hosting.Maui` adds a spurious `run` positional to the launch arguments of resources created via `AddAndroidEmulator()` (and `AddAndroidDevice()`). The dispatched command becomes `dotnet run … --no-launch-profile run -f net10.0-android …`. `Microsoft.Android.Run` (the SDK MSBuild target the Android dispatch invokes) rejects the extra positional with:
```
Error: Unexpected argument(s): run
Try 'Microsoft.Android.Run --help' for more information.
```
The same builder-emitted command is tolerated by iOS Simulator and Mac Catalyst targets, so only the Android entry fails.
## Reproduction
`Aspire.Hosting.Maui` 13.2.4-preview.1.26224.4 on .NET 10 SDK 10.0.103, MAUI workload 10.0.20/10.0.100, Android workload 36.1.53/10.0.100. macOS 25.4.0 (Apple Silicon).
AppHost.cs:
```csharp
var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("participant-mobile",
"../../Frontend/Surfaces/Participant.Mobile/Participant.Mobile.csproj");
maui.AddAndroidEmulator()
.WithOtlpDevTunnel()
.WithReference(gateway, publicTunnel);
builder.Build().Run();
```
Then `aspire start` and click the Android Emulator entry in the dashboard.
The resource console shows:
```
[sys] Starting process...: Cmd = .../dotnet, Args = [
"run", "--project", "Participant.Mobile.csproj",
"--configuration", "Debug", "--no-launch-profile",
"run", // <-- spurious
"-f", "net10.0-android",
"-p:AdbTarget=-e",
"-p:CustomAfterMicrosoftCommonTargets=…"
]
Error: Unexpected argument(s): run
Try 'Microsoft.Android.Run --help' for more information.
The build failed. Fix the build errors and run again.
```
iOS Simulator launches with the same shape (also has the duplicate `run`) but its dispatch tolerates the extra positional and the app boots.
## Expected
`AddAndroidEmulator()` should not append the second `run` token; the Android MSBuild target's argument parser is stricter than iOS / MacCatalyst and rejects unknown positionals.
## Workaround in user code
```csharp
maui.AddAndroidEmulator()
.WithReference(gateway, publicTunnel)
.WithArgs(ctx => ctx.Args.Remove("run"));
```
The actual `dotnet run` verb is in a separate launch slot, so `Args.Remove(\"run\")` only strips the spurious positional.
## Related
We first hit this in March 2026 against an earlier `Aspire.Hosting.Maui` preview; we shipped the same `WithArgs(ctx => ctx.Args.Remove(\"run\"))` workaround at that time. Bug remains in 13.2.4-preview.1.26224.4. Would be ideal to fix at the source so each new MAUI project doesn't have to remember the workaround.
## Environment
| | |
|---|---|
| Aspire CLI | 13.3.0 |
| Aspire.Hosting | 13.3.0 |
| Aspire.Hosting.Maui | 13.2.4-preview.1.26224.4 |
| Aspire.Hosting.DevTunnels | 13.3.0 |
| .NET SDK | 10.0.103 |
| MAUI workload | 10.0.20/10.0.100 |
| Android workload | 36.1.53/10.0.100 |
| iOS workload | 26.4.10259/10.0.100 |
| Mac Catalyst workload | 26.4.10259/10.0.100 |
| Host OS | macOS 25.4.0 (Apple Silicon) |
Contributor guide
Assessment
This issue has not been assessed yet.