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
Steps to reproduce the behavior:
dotnet new blazorhosted -o HostedTest
cd HostedTest\HostedTest.Server
dotnet publish -c Release -o bin\release\publish
cd bin\release\publish
dotnet HostedTest.Server.dll
http://localhost:5000
=> 404It 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
Perhaps this is the same as/related to #10878 and #11088 ?
@mkArtakMSFT Please assign
I can confirm the same problem has happened to me. To fix the error I had to manually copy all of the files in the wwwroot to my production server.
Workaround for that for me was following
#if DEBUG
endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html");
#else
endpoints.MapFallbackToClientSideBlazor<Client.Startup>("_content/client_project_name/index.html");
#endif
Is there a work around to fix this. even though i made the site work on kestral. i cant make the iis version work
@smartprogrammer93, have you tried the workaround provided by @kant2002 above?
@mkArtakMSFT yes. It only worked with kestral but not with IIS. I even copied the content of the folder to the wwroot. And that made kestral work but not IIS
Not really sure this is the same, but have you tried the workaround described here: https://github.com/aspnet/websdk/issues/604
@danroth27, I moved this out to 3.1, as the other related/similar issues are in there already and we can't fit this in current milestone.
@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.
I believe this is actually fixed as per my changes in https://github.com/aspnet/AspNetCore/commit/0a4f42a7e2030697ecf2c35b5de8b524b8bbf42f.
Workaround for that for me was following
#if DEBUG endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html"); #else endpoints.MapFallbackToClientSideBlazor<Client.Startup>("_content/client_project_name/index.html"); #endif
This works but you also need to do the same for the static files
@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?
@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("")
});
Most helpful comment
I believe this is actually fixed as per my changes in https://github.com/aspnet/AspNetCore/commit/0a4f42a7e2030697ecf2c35b5de8b524b8bbf42f.