New dotnet watch support for aspire#14327
Closed
tmat wants to merge 13 commits intodotnet:feature/watch-prototypefrom
Closed
New dotnet watch support for aspire#14327tmat wants to merge 13 commits intodotnet:feature/watch-prototypefrom
tmat wants to merge 13 commits intodotnet:feature/watch-prototypefrom
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14327Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14327" |
Member
Author
Member
|
How is the host command special? |
Member
Author
That one is equivalent to regular |
Add centralized hot reload support via Watch.Aspire server: - DcpExecutor creates a hidden watch server ExecutableResource when DOTNET_WATCH=true and WatchAspirePath is configured - Project resources use the Watch.Aspire `resource` command instead of `dotnet run`, with env vars passed as -e args - Resource command stays alive proxying stdout/stderr from the server back to DCP via named pipe output protocol - Server-side ProcessLauncherFactory forwards process output/exit over the pipe instead of disposing it after ACK Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Shorten named pipe name to fit macOS 104-char Unix socket limit - Fix SDK path resolution to derive from runtime directory instead of process path - Add Microsoft.CodeAnalysis.* to dotnet-public package source mapping - Add VersionOverride for Microsoft.Build.Framework in Watch.Aspire Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add WatchControlCommand and WatchStatusEvent types for bidirectional communication - Implement WatchControlReader/WatchStatusWriter for stdio-based protocol - Update DcpExecutor to send watch commands and receive status events - Add WatchAspireAnnotation and WatchAspireEventHandlers for resource integration - Expand DotnetSdkUtils with SDK resolution and project launch info helpers - Update ProcessLauncherFactory to support Aspire-hosted watch scenarios - Wire up watch options and context for hot reload coordination
tmat
commented
Feb 17, 2026
| return 0; | ||
| } | ||
|
|
||
| static async Task ListenForControlCommandsAsync( |
Member
Author
There was a problem hiding this comment.
This allows restarting all resource projects, but wouldn't we rather want to restart individual resource projects?
tmat
commented
Feb 17, 2026
| buildArguments: _context.BuildArguments, | ||
| onLaunchedProcessCrashed: () => | ||
| { | ||
| // Mirror the root process onExit behavior (line 154-159): |
Member
Author
There was a problem hiding this comment.
This doesn't look right. Do we actually want to restart everything if one of the resource process crashes? I guess not. We want to restart just that one process, right?
Member
Author
|
Superseded by #14947 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds more functionality to Aspire.Watch CLI tool. Aspire can invoke it via CLI or you can also run some of it in-proc, as needed.
Defines 3 CLI commands:
host,serverandresource.hostruns AppHost:serverruns Hot Reload server and you pass it a set of C# resource projects or .cs files for file-based apps. It also takes a unique named pipe name to listen on:resourcelaunches resource project:This command also takes parameters like
--environment,--launch-profile, etc.It sends request to launch an app to the server.
Bidirectional control protocol (AppHost ↔ Watch Server)
This update adds a status/control pipe protocol between the AppHost and the Watch.Aspire server:
Status events (Watch Server → AppHost):
The watch server reports lifecycle events back to the AppHost over a named pipe (
--status-pipe). The AppHost uses these to update resource states in the Dashboard:building/build_complete(with success/failure)hot_reload_appliedrestartingprocess_started/process_exited(with exit code)Control commands (AppHost → Watch Server):
The AppHost sends commands to the watch server over a named pipe (
--control-pipe):rebuild— triggers a forced rebuild and restart for specific projectsDashboard integration:
Crash recovery:
Other changes:
DotnetSdkUtilsexpanded withTryGetSdkDirectoryAsyncusingdotnet --list-sdksfor accurate SDK resolution (respectsglobal.json)WatchAspireEventHandlers(eventing subscriber) for cleaner separation fromDcpExecutor.in.targetsto use$(OS) != 'Windows_NT'instead ofIsOsPlatform('OSX')for non-Windows DLL path resolution