lonix
lonix

Reputation: 20529

Purpose of Microsoft.AspNetCore.Components.WebAssembly.Server package

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.)

Upvotes: 10

Views: 2760

Answers (1)

MrC aka Shaun Curtis
MrC aka Shaun Curtis

Reputation: 30036

If you comment out the package and then rebuild the Server project you'll get the following errors in Program:

enter image description here

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.

Upvotes: 7

Related Questions