'How to publish Blazor WebAssembly with ASP.NET Core hosted

I would like to know how do I publish a Blazor WebAssembly application with ASP.Net Core Hosted checked. The big problem is that in the application they have 2 projects, and I don't know which one to publish, or how to merge between them when publishing.



Solution 1:[1]

Publish the Server app.

When you look in its \bin\Release folder you will see the Client related DLLs as well.

Don't overthink it.

Solution 2:[2]

You need to publish your Server project.

But it must have a reference to your Client's project.

In versions < 3.2.0 you must also register Blazor on your server application.

Here's how to register it in your server Startup (Replace Client with the proper namespace in your Blazor project):

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBlazorDebugging();
            }
        app.UseStaticFiles();
        app.UseClientSideBlazorFiles<Client.Startup>();
        app.UseEndpoints(endpoints =>
        {
                endpoints.MapDefaultControllerRoute();
                endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html");
         });
     }

Solution 3:[3]

Publish the server project, it will include the client assemblies in its output, Make sure you have installed the .Net core hosting bundle in your server.

https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-6.0.3-windows-hosting-bundle-installer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henk Holterman
Solution 2
Solution 3 tellyman