aspnetcore: [Blazor] Preview 6 blazorhosted project publish is broken

Describe the bug

Using preview 6 sdk/templates, when publishing a blazor hosted project, publish output seems broken and trying to run the published app does not work

To Reproduce

Steps to reproduce the behavior:

  1. dotnet new blazorhosted -o HostedTest
  2. cd HostedTest\HostedTest.Server
  3. dotnet publish -c Release -o bin\release\publish
  4. cd bin\release\publish
  5. dotnet HostedTest.Server.dll
  6. Navigate to http://localhost:5000 => 404

Additional context

It seems that the publish output folder is not right. For example the index.html file is missing from the HostedTest.Client\dist folder. Here is the kestrel log of the request

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://localhost:5000/
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Fallback {*path:nonfile}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Fallback {*path:nonfile}'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 27.119500000000002ms 404

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@mkArtakMSFT i will try this workaround when i have the time. Please note that moving this issue to to 3.1 milestone means that client blazor apps will never be able to be hosted in IIS which a lot of us use. I argue guys to reconsider.

@mkArtakMSFT i will try this workaround when i have the time. Please note that moving this issue to to 3.1 milestone means that client blazor apps will never be able to be hosted in IIS which a lot of us use. I argue guys to reconsider.

I could not agree more. It seems like it would be a huge miss to move this to 3.1, it’s not like this is a feature request to get publishing into IIS, this is a regression bug. Preview 5 worked just fine with IIS publishing.

@FluentGuru Hey, I’m just starting out with all of this. I got the MapFallbackToClientSideBlazor DEBUG snippet above working for me. But my site has no static files. Where and what do I change in order to do the same for static files as you say?

@DustinCampbell you must add this part too if you are using static files found inside your blazor project folder

app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/_content/{blazorprojectname}")),
                RequestPath = new PathString("")
            });