Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 729
lonix Avatar asked Apr 29 '26 14:04

lonix


1 Answers

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.

like image 106
MrC aka Shaun Curtis Avatar answered May 02 '26 04:05

MrC aka Shaun Curtis