I'm using ASP.NET Core 6. I'm trying to add a blazor project to an existing monorepo that includes a web API server project. I ran dotnet new blazorwasm --hosted, and the generated server project includes this package:
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.4" />
What is its purpose - do I need it? The docs say:
Provides types for hosting the Blazor development server locally. Intended for framework use only, not supported for use in application code.
That's confusing - why is it included in the template? And it's not hidden behind a Development environment build step.
Also, how does it differ to the Microsoft.AspNetCore.Components.WebAssembly.DevServer package?
(The generated client blazor project also references Microsoft.AspNetCore.Components.WebAssembly and Microsoft.AspNetCore.Components.WebAssembly.DevServer. I'm curious how all these are related.)
If you comment out the package and then rebuild the Server project you'll get the following errors in Program:

They contain the middleware that maps the correct project files and infrastructure in the hosted server project. An example is mapping the client project wwwroot directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With