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

1.9k Views Asked by At

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

1

There are 1 best solutions below

3
MrC aka Shaun Curtis On BEST ANSWER

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.