Aspire AppHost does not shut down projects gracefully
- 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
Using the stop button on a project in Aspire Dashboard does not shut down the project gracefully, causing any shutdown operations to be skipped which causes issues for services that does this. E.g., I am communicating in my service with a 3rd party service which requires a cleanup process when not using them anymore.
I have tried to find what exactly you do, but it stopped finding the cause when I hit some patch operations against K8s (but this isn't executed in K8s, so I lost the tracking).
The projects is also not shut down gracefully when I shut down the app host gracefully either.
### Expected Behavior
Stopping the project in any way should trigger a graceful shutdown (similar to CTRL+C) so that the process can perform cleanup logic during shutdown.
### Steps To Reproduce
- Create a ASP.NET Aspire Starter App project
- After the `var app = builder.Build();` statement in `ApiService/program.cs` add the following:
```
app.Lifetime.ApplicationStopping.Register(() =>
{
app.Logger.LogInformation("Application stopping. Performing graceful shutdown tasks...");
});
```
- Set a breakpoint in the action body
- Run the AppHost project
- After everything has started either:
- stop the `apiservice` project
- press `CTRL+C` in the AppHost console
Result: The stopping action is not called
### Exceptions (if any)
_No response_
### .NET Version info
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.