microsoft / microsoft/aspire

WaitForCompletion seems incompatible with watch

Open
#9,756 6 comments 3 reactions 1 assignee Claimed by @tmat View on GitHub
area-tooling
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

TL;DR: `WaitForCompletion` does not work when using `dotnet watch` or `aspire run --watch`

We are playing with Aspirifying a .NET 8 Blazor (server) app which uses EF Core with Postgresql. We're using Aspire 9.3 and generally use the 8.0 SDK but have also tested with the 9.0 SDK before opening this issue.

* Following the guidelines we created a separate 'Migrations' project to run the EF migrations (and seeding) at startup.
* In order to make sure the migrations complete before the app tries to start, we had to add `WaitForCompletion` to the app service. This works OK when using `aspire run`
* Because this is Blazor server app, we need to use `dotnet watch` (or `aspire run --watch`) for any kind of realistic development loop performance. Unfortunately when running AppHost under either of those CLI-based watch commands, the Migrations service does not actually complete. This means that the web app never starts, because of its `WaitForCompletion`
* Manually clicking 'stop' on the Migrations service in the dashboard does release the web app to start.

I have not tried any kind of IDE-based hot-reload.

There was a previous mention of this here, but it was an addition to an issue which is now closed: https://github.com/dotnet/aspire/issues/6695#issuecomment-2510297236

I doubt "Blazor + EF Migrations" really qualifies as a corner-case so I am probably missing something here, but if I'm not, could we we have one of these:

* Some way to manually mark a service as not-for-hot-reload (clearly it's just useless busywork on a one-shot app anyway)
* Aspire could detect the `WaitForCompletion` and mark the relevant service as not-for-hot-reload
* The `WaitForCompletion` logic could understand the 'watch' quirks a little better and work around them

I am currently running on a Mac but can test on Windows if that might be relevant.

### Expected Behavior

I expect that using watch/hot reload should be compatible with using `WaitForCompletion`

### Steps To Reproduce

Minimal repro:

https://github.com/willdean/aspire-watch-start-issue

### Exceptions (if any)

_No response_

### .NET Version info

.NET SDK:
Version: 9.0.203
Commit: dc7acfa194
Workload version: 9.0.200-manifests.87b8cca8
MSBuild version: 17.13.20+a4ef1e90f

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.5
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.203/

.NET workloads installed:
[aspire]
Installation Source: SDK 9.0.200
Manifest Version: 8.2.2/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.2.2/WorkloadManifest.json
Install Type: FileBased

Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.4
Architecture: arm64
Commit: f57e6dc747

.NET SDKs installed:
6.0.418 [/usr/local/share/dotnet/sdk]
7.0.404 [/usr/local/share/dotnet/sdk]
8.0.100 [/usr/local/share/dotnet/sdk]
8.0.404 [/usr/local/share/dotnet/sdk]
8.0.407 [/usr/local/share/dotnet/sdk]
9.0.203 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.26 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.26 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.