Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pcannon-b2w opened this issue Nov 21, 2024 · 1 comment
Open
Assignees

Comments

@pcannon-b2w
Copy link

pcannon-b2w commented Nov 21, 2024

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

  • Include the output of dotnet --info
.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
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Watch untriaged Request triage from a team member labels Nov 21, 2024
@tmat tmat self-assigned this Nov 24, 2024
@tmat tmat removed the untriaged Request triage from a team member label Nov 24, 2024
@Juulsn
Copy link

Juulsn commented Nov 27, 2024

I'm seeing the following issue after the merge of this into 9.0.2xx

dotnet watch ⌚ File updated: /Users/me/RiderProjects/Shared.Frontend/Components/Shared/Buttons/MyButton.razor.css
dotnet watch ⌚ [Web (net9.0)] Exited
dotnet watch ⌚ [ApiService (net9.0)] Exited
dotnet watch ⌚ [Admin (net9.0)] Exited
dotnet watch ⌚ [AppHost (net9.0)] Exited
dotnet watch ⏳ Waiting for a file to change before restarting ...
dotnet watch ❌ System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DotNet.Watch.ScopedCssFileHandler.HandleBrowserRefresh(BrowserRefreshServer browserRefreshServer, String containingProjectPath, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.ScopedCssFileHandler.<>c__DisplayClass5_0.<<HandleFileChangesAsync>b__2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Watch.ScopedCssFileHandler.HandleFileChangesAsync(IReadOnlyList`1 files, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.Program.RunAsync()
dotnet watch ❌ An unexpected error occurred

Process finished with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants