C
C#8mo ago
eggsaVEVO

❔ Two Program.cs files in new Blazor Web App template.

After playing around with the preview version of .NET 8 I noticed that in the new Blazor Web App template (which combines webassembly and server side rendering) there are two Program.cs files. I get that for each environment an individual entry point is needed. But its somewhat magic to me how Blazor knows which main function to call. Does the assembly generated by the client project have some special attributes that allows the Blazor app to know that this is the dll for the webassembly rendering or how exactly does this work?
7 Replies
ZacharyPatten
ZacharyPatten8mo ago
at first glance I assume that is a bug yeah there is definitely a bug imo... even if you select "none" it still gives you a project template
ZacharyPatten
ZacharyPatten8mo ago
I think these options in the drop down are jumbled up
No description
ZacharyPatten
ZacharyPatten8mo ago
that is a new in VS 2022 preview 17.8.0 preview 6.0 it isn't in the current 17.7.6 either a bug or the UI there is misleading
eggsaVEVO
eggsaVEVO8mo ago
I don't think its a bug. At least not the Auto template (didn't try the single mode templates). It fits perfectly with the project structure described here: https://learn.microsoft.com/en-us/aspnet/core/blazor/project-structure?view=aspnetcore-8.0
ASP.NET Core Blazor project structure
Learn about ASP.NET Core Blazor app project structure.
ZacharyPatten
ZacharyPatten8mo ago
running dotnet new blazorwasm only makes one prject but in the Visual Studio ui it makes 2 projects
eggsaVEVO
eggsaVEVO8mo ago
Try running only blazor e.g. dotnet new blazor This should create the auto template app. blazorwasm is wasm only
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.