Skip to content

WaitForCompletion seems incompatible with watch #9756

@willdean

Description

@willdean

Is there an existing issue for this?

  • 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: #6695 (comment)

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions