Open warappa opened 3 years ago
It isn't just the WebView component, it is Blazor related.
I created a Blazor-Server project, started it, then in MainLayout.razor.css
I commented out that one single line inside .sidebar
, pressed Ctrl+S, but in Edge the changes didn't reflect. I had to restart the whole application to see the changes in the CSS file. Not really convenient...
When I moved <h1>Counter</h1>
in Counter.razor
below the button and pressed Ctrls+S, the changes automatically reflected in the browser.
(I have Hot Reload on File Save enabled).
Microsoft Visual Studio Community 2022 Preview (64-bit) Version 17.0.0 Preview 7.0 OS: Windows 7
Same here
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Hot reload is not working for CSS as mentioned in this dotnet video https://youtu.be/GKu-vRxOWr8?t=635 The Video mentions that as soon as we update the CSS it should reflect. but for me its not working even after saving the file. I had to restart the application.
@farhan7272 are you on Windows 7? Because I had the same issue on Windows 7, but on Windows 10 it works fine, even scoped CSS hot reloads instantly (you have to press the save button for that though).
this is still a problem in dotnet 7
Here is a repo with reproduction: https://github.com/qrzychu/WpfBlazorHybrid
It even contains the hack from @warappa
This is especially annoying when everything else works just fine: updating the razor files, updating just C# code. Everything works fine, except of the CSS, which would be most helpfull.
Hot reloading of the css works for me in Firefox 107, but not in Safari 16.2. Manually reloading does apply the changes. This is on .NET 6. I do need to have webBuilder.UseStaticWebAssets();
in my Program.cs
, otherwise the CSS isn't rebuild during hot reload.
Describe the bug
Hot reloading scoped css works for Blazor Server and should also work for Blazor within WebView2 with
Microsoft.AspNetCore.Components.WebView.Wpf
package.Unfortunately, it doesn't.
Curiously, hot reloading DOM changes like editing the text of an h1 element works as expected.
As shown below,
dotnet watch
does somewhat work for css (with manual/hacky workarounds). VS 2022 Hot Reload does not update the generated bundle css file and therefore does not work at all.To Reproduce
Counter.razor.css
and a style likedotnet watch --verbose
in the command line in the project-directoryblue
dotnet watch
outputs updated file but it's not reflected in-appWorkaround 1 (With dotnet watch)
Click somewhere in the app window and press CTRL+R
Workaround 2 (With dotnet watch)
Force reloading of css with timer in JS in
index.html
(for a project namedWpfApp1
):Further technical details
dotnet --info
:dotnet --info Output
``` .NET SDK (reflecting any global.json): Version: 6.0.100-rc.2.21505.57 Commit: ab39070116 Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\ Host (useful for support): Version: 6.0.0-rc.2.21480.5 Commit: 6b11d64e7e .NET SDKs installed: 3.1.412 [C:\Program Files\dotnet\sdk] 5.0.301 [C:\Program Files\dotnet\sdk] 5.0.400 [C:\Program Files\dotnet\sdk] 5.0.402 [C:\Program Files\dotnet\sdk] 6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] ```