Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Hot Reload issue with .NET 8

$
0
0

I have a very specific CSS hot reload issue during VS 2022 17.11.4 debugging sessions with my Blazor .NET 8 server app - I think the fine details matter here.

My scoped CSS file appears in the subfolder:

\obj\Debug\net8.0\scopedcss\bundle\MyNamesapce.styles.css

but never anywhere else, e.g. bin.

The .csproj includes these lines:

<TargetFramework>net8.0</TargetFramework><EnableScopedCss>true</EnableScopedCss>

App.razor contains:

<link rel="stylesheet" href="/MyNamespace.styles.css?v=@DateTime.Now.Ticks" asp-append-version="true" />

Program.cs contains:

var builder = WebApplication.CreateBuilder(args);// Add services to the container.builder.Services.AddRazorComponents()    .AddInteractiveServerComponents();var app = builder.Build();// Configure the HTTP request pipeline.if (!app.Environment.IsDevelopment()){    app.UseExceptionHandler("/Error", createScopeForErrors: true);    app.UseHsts();}app.UseHttpsRedirection();app.UseStaticFiles();app.UseAntiforgery();app.MapRazorComponents<App>()    .AddInteractiveServerRenderMode();app.Run();

However the only way to get close to hot reload is to use dotnet watch run from the developer PowerShell and even THEN I have to F5 the browser to reload the CSS.

Without using dotnet watch run ... the scoped CSS changes don't get applied at all until stopping and rebuilding/restarting the project.

The file in the obj scopedcss folder DOES change when one of the scoped .razor.css files changes during a debugging runtime - but only if started with dotnet watch run.

Any ideas?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>