最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Blazor Hot Reload issue with .NET 8 - Stack Overflow

programmeradmin4浏览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="/[email protected]" 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.UseAntifery();

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?

发布评论

评论列表(0)

  1. 暂无评论