dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.59k stars 393 forks source link

Support for older ASP.NET Core hosting models - IWebHost, IHostBuilder #1057

Open Swellenator opened 9 months ago

Swellenator commented 9 months ago

I have just updated an existing ASP.NET Core app to .NET 8. I tried to add .NET Aspire Orchestrator support via the Visual Studio tooling and received this error:

Microsoft Visual Studio Failed to insert code for project [ApiProject]. Cant find a call to method(s) Build on type Microsoft.AspNetCore.BuiIder.WebAppIicationBuiIder in the program main.

After some digging I have concluded it is due to an older unsupported hosting model, IWebHost. I updated to a newer IHostBuilder, but still no luck. It looks like ASP.NET Aspire requires IHostApplicationBuilder.

I think this should be made clearer at least in the documentation. It would be good to have a note stating that you need to be using IHostApplicationBuilder not just .NET 8.

I would also consider making the error from the tooling a bit better. It is clear from the Extensions part of ServiceDefaults project that you need to use IHostApplicationBuilder, but when relying on tooling the error message doesn't help that much.

varndellwagglebee commented 2 months ago

Is there an updated on this? I too need IHostBuilder