问题
I recently re-installed my dev machine and Visual Studio is not behaving like it used to. I must have missed an important setting. I used to be able to modify the html or css files within my ASP.NET Core 3.1 app while debugging. After I saved the files and refreshed my browser, the changes were present. That is no longer the case, I'm losing so much time restarting my debugging sessions. Anyone know what I'm missing?
回答1:
After I saved the files and refreshed my browser, the changes were present. That is no longer the case, I'm losing so much time restarting my debugging sessions. Anyone know what I'm missing?
The main issue is that since .Net Core 3.0, if you want to debug edited content in real time, you should install a nuget package called Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
and then do some extra changes manually.
Before .Net Core 2.2, there was no need to worry about this. So when you debug projects based on Net Core 3.0 or above, you can try these:
Solution
1) try to install a nuget package called Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation into your project. And note that your project is based on .Net Core 3.1, so you should install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 3.1
version.
2) do some changes in your startup page. In my side, it is Startup.cs
file and then add these in the ConfigureServices
function.
services.AddRazorPages().AddRazorRuntimeCompilation();
More info you can refer to this.
Hope it could help you.
来源:https://stackoverflow.com/questions/59444770/visual-studio-community-2019-save-html-and-css-files-while-debugging