microsoft / microsoft/aspire

Add watch/restart support for Rust AppHosts

Open
#19,376 1 comment 0 reactions 0 assignees View on GitHub
area-polyglot area-vscode triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Background

#18906 adds Rust AppHost run and debug support. `RuntimeSpec.WatchExecute` remains unset, so watch mode currently launches the Rust AppHost normally but does not restart it after source changes.

We should provide the same edit/run loop available to other AppHost languages. This should not depend on the archived `cargo-watch`, silently require a globally installed tool, or weaken AppHost shutdown behavior.

### Requirements

- Restart the Rust AppHost when relevant Rust, Cargo, or generated module inputs change.
- Ignore build output and unrelated workspace changes.
- Stop the previous AppHost gracefully before starting its replacement, including on Windows.
- Preserve Aspire arguments and environment variables across restarts.
- Re-establish the CLI backchannel after each restart without leaving orphaned resources or occupied ports.
- In VS Code debug mode, restart or reattach the native debugger so breakpoints continue to work after the executable PID changes.
- Keep publish behavior unchanged.
- Provide actionable prerequisite UX if an external watcher is selected.

### Design notes

`WatchExecute` can select another command, but the current runtime contract does not model optional tool prerequisites, fallback behavior, or watcher-specific child termination. The Rust debugger also builds and launches one executable per debug session, so wrapping `cargo run` with a watcher is not sufficient for debug parity.

We should evaluate a maintained watcher such as Bacon against an Aspire-owned process supervisor. The implementation should include cross-platform tests for process replacement, backchannel reconnection, and debugger behavior.

Contributor guide

Open the contributing guide

Research direction

Start by tracing RuntimeSpec.WatchExecute and the Rust AppHost run/debug path introduced by #18906. Compare a maintained watcher such as Bacon with an Aspire-owned supervisor, then add cross-platform tests for process replacement, backchannel reconnection, and debugger restart or reattach. Done means watch, debug, shutdown, argument, environment, and publish behavior meet the stated requirements.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, rust, vscode
Domain
developer-experience, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.