Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Add ADB reverse port forwarding support #303

Description

@rmarinho

Summary

Add support for ADB reverse port forwarding to AdbRunner (or a new helper), enabling the MAUI DevTools CLI to manage hot-reload tunnels without going through ServiceHub.

Context

The VS Code MAUI extension currently uses the C# ServiceHub (AndroidDeviceManager.reversePort() / killReverse()) to set up reverse port forwarding for .NET Hot Reload. As part of the ServiceHub → CLI migration (see dotnet/android#12073 for related device monitoring work), we need these ADB operations exposed as library APIs that the MAUI DevTools CLI can call.

What the ServiceHub does today

From Microsoft.VisualStudio.Maui.Devices:

  • reversePort(deviceSerial, remotePort, localPort) → runs adb -s <serial> reverse tcp:<remote> tcp:<local>
  • killReverse(deviceSerial, remotePort) → runs adb -s <serial> reverse --remove tcp:<remote>

Consumer

  • VS Code extension: MauiAndroidPlatform.tscreateLocalTunnels() (sets up hot reload tunnel on deploy)
  • VS Code extension: MauiAndroidPlatform.tscleanUpDebugSession() (removes tunnel on stop)

Proposed API

Add to AdbRunner (or create AdbPortForwarder):

`csharp
// Set up reverse port forwarding
Task ReversePortAsync(string deviceSerial, int remotePort, int localPort, CancellationToken ct = default);

// Remove a specific reverse port forwarding rule
Task RemoveReversePortAsync(string deviceSerial, int remotePort, CancellationToken ct = default);

// List active reverse port forwarding rules (optional, nice-to-have)
Task<IReadOnlyList> ListReversePortsAsync(string deviceSerial, CancellationToken ct = default);
`

CLI Command (downstream in dotnet/maui)

Once the API exists here, the MAUI DevTools CLI will expose:
maui android adb reverse --device <serial> --remote tcp:<port> --local tcp:<port> --json maui android adb reverse --remove --device <serial> --remote tcp:<port> --json

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions