dotnet / dotnet/android

Add ADB file push support for device file operations

Open
#12,074 0 comments 0 reactions 0 assignees View on GitHub
android-tools enhancement needs-triage
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 21h
Merged PRs (30d)
257

Description

## 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 push `

### 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 --remote-path --content "..." --json
maui android adb push --device --remote-path --local-path --json
`

## Related

- dotnet/android#12073 — ADB track-devices support
- dotnet/android-tools#303 — ADB reverse port forwarding
- ServiceHub migration tracking in vscode-maui (`dev/rumar/android-maui-tool` branch)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.