Summary
Add support for pushing content/files to a device via ADB, enabling the MAUI DevTools CLI to write files to connected devices without going through ServiceHub.
Context
The VS Code MAUI extension currently uses the C# ServiceHub (AndroidDeviceManager.createFile()) to push files to Android devices. This is used during debugging to write XAML Hot Reload environment variables to the device filesystem. As part of the ServiceHub → CLI migration, we need this as a library API.
What the ServiceHub does today
From Microsoft.VisualStudio.Maui.Devices:
createFile(deviceSerial, remotePath, content) → writes content to a temp file, then runs adb -s <serial> push <tempFile> <remotePath>
Consumer
- VS Code extension:
MauiAndroidPlatform.ts → setXamlToolsEnvironmentVariables() (writes env config file to device for XAML Hot Reload)
Proposed API
Add to AdbRunner:
`csharp
// Push a local file to the device
Task PushFileAsync(string deviceSerial, string localPath, string remotePath, CancellationToken ct = default);
// Push string content to a remote path (writes to temp file, pushes, cleans up)
Task PushContentAsync(string deviceSerial, string content, string remotePath, CancellationToken ct = default);
// Pull a file from the device (optional, nice-to-have)
Task PullFileAsync(string deviceSerial, string remotePath, string localPath, CancellationToken ct = default);
`
CLI Command (downstream in dotnet/maui)
Once the API exists here, the MAUI DevTools CLI will expose:
maui android adb push --device <serial> --remote-path <path> --content "..." --json maui android adb push --device <serial> --remote-path <path> --local-path <file> --json
Related
Summary
Add support for pushing content/files to a device via ADB, enabling the MAUI DevTools CLI to write files to connected devices without going through ServiceHub.
Context
The VS Code MAUI extension currently uses the C# ServiceHub (
AndroidDeviceManager.createFile()) to push files to Android devices. This is used during debugging to write XAML Hot Reload environment variables to the device filesystem. As part of the ServiceHub → CLI migration, we need this as a library API.What the ServiceHub does today
From
Microsoft.VisualStudio.Maui.Devices:createFile(deviceSerial, remotePath, content)→ writescontentto a temp file, then runsadb -s <serial> push <tempFile> <remotePath>Consumer
MauiAndroidPlatform.ts→setXamlToolsEnvironmentVariables()(writes env config file to device for XAML Hot Reload)Proposed API
Add to
AdbRunner:`csharp
// Push a local file to the device
Task PushFileAsync(string deviceSerial, string localPath, string remotePath, CancellationToken ct = default);
// Push string content to a remote path (writes to temp file, pushes, cleans up)
Task PushContentAsync(string deviceSerial, string content, string remotePath, CancellationToken ct = default);
// Pull a file from the device (optional, nice-to-have)
Task PullFileAsync(string deviceSerial, string remotePath, string localPath, CancellationToken ct = default);
`
CLI Command (downstream in dotnet/maui)
Once the API exists here, the MAUI DevTools CLI will expose:
maui android adb push --device <serial> --remote-path <path> --content "..." --json maui android adb push --device <serial> --remote-path <path> --local-path <file> --jsonRelated
dev/rumar/android-maui-toolbranch)