Skip to content

Trigger msbuild target when hot reload detects Razor file change (Blazor) #33861

@MisterGoodcat

Description

@MisterGoodcat

I'm using .NET 6.0.100-preview.5.21302.13 and Blazor Server.

I am trying to integrate a CSS framework (tailwind/postcss) with hot reload. My approach is to extend my project file with custom targets to trigger the CSS pre-compile. For scoped CSS this actually works great: I inspect and process the generated scoped files after the target "_GenerateScopedCssFiles" is completed.

When a .razor file is edited though, I cannot seem to find an msbuild target that I can attach my custom logic to as before/after target. I grepped through a verbose log created from "dotnet build" to identify something suitable but no success.

What exactly happens during hot reload when a .razor file changes? Is there some msbuild targets involved at all? The verbose output of "dotnet watch" does not give any clues.

My workaround currently is to run a separate watcher (here: tailwind CLI) for these files, and let "dotnet watch" then process the resulting static CSS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Componentsfeature-hot-reloadThis issue is related to the Hot Reload feaature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions