dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

dotnet watch reloading of razor class library CSS has regressed in 9.0 #45011

Open pcannon-b2w opened 4 days ago

pcannon-b2w commented 4 days ago

Describe the bug

After upgrading our tooling to NET 9.0, the dotnet watch command is no longer actively reloading CSS when changes are made to referenced Razor Class Library projects using CSS Isolation.

On NET 8.0 after making a change to a Component's CSS, the bundled CSS is reloaded and the page is updated. On NET 9.0, dotnet watch detects the change and says it has reloaded the CSS but no changes are made to the page and no new CSS is retrieved in the Network tab of the browsers debug tools.

To Reproduce

Repo: https://github.com/pcannon-b2w/dotnet-watch-regression

  1. From the net8.0 folder run dotnet watch against the CssIsolationIssue.sln solution
  2. In RazorClassLibrary\Components\Example.razor.css change the color from red to blue
  3. Save

dotnet watch will reload the page and the color of the Hello World text will change:

Image

dotnet watch ⌚ File changed: D:\Code\dotnet-watch-regression\net8.0\RazorClassLibrary\Components\Example.razor.css.
dotnet watch 🔥 Hot reload of scoped css succeeded.
  1. From the net9.0 folder run dotnet watch against the CssIsolationIssue.sln solution
  2. In RazorClassLibrary\Components\Example.razor.css change the color from red to blue
  3. Save

dotnet watch will detect the change but no CSS is reloaded on the page:

Image

dotnet watch ⌚ File added: D:\Code\dotnet-watch-regression\net9.0\RazorClassLibrary\Components\Example.razor.css~
dotnet watch ⌚ File updated: D:\Code\dotnet-watch-regression\net9.0\RazorClassLibrary\Components\Example.razor.css
dotnet watch ⌚ File added: D:\Code\dotnet-watch-regression\net9.0\RazorClassLibrary\Components\Example.razor.css~
dotnet watch ⌚ File updated: D:\Code\dotnet-watch-regression\net9.0\RazorClassLibrary\Components\Example.razor.css
dotnet watch 🔥 Hot reload of scoped css succeeded.
dotnet watch ⌚ No hot reload changes to apply.

Further technical details

.NET SDK:
 Version:           9.0.100
 Commit:            59db016f11
 Workload version:  9.0.100-manifests.c6f19616
 MSBuild version:   17.12.7+5b8665660

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  7.0.410 [C:\Program Files\dotnet\sdk]
  8.0.404 [C:\Program Files\dotnet\sdk]
  9.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  D:\Code\dotnet-watch-regression\net9.0\global.json