Visual Studio Community 2019调试时保存HTML和CSS文件 [英] Visual Studio Community 2019 Save HTML and CSS Files While Debugging

查看:47
本文介绍了Visual Studio Community 2019调试时保存HTML和CSS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近重新安装了我的开发机,而Visual Studio的运行方式却不像以前那样.我一定错过了一个重要的背景.我曾经能够在调试时修改ASP.NET Core 3.1应用程序中的html或css文件.保存文件并刷新浏览器后,便出现了更改.情况不再如此,我失去了太多时间来重新启动调试会话.有人知道我想念什么吗?

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?

推荐答案

保存文件并刷新浏览器后,所做的更改是展示.情况不再如此,我正在浪费太多时间重新启动我的调试会话.有人知道我想念什么吗?

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?

主要问题是,从 .Net Core 3.0 开始,如果要实时调试已编辑的内容,则应安装一个名为 Microsoft.AspNetCore.Mvc.Razor的nuget程序包.RuntimeCompilation ,然后手动进行一些额外的更改.

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.

.Net Core 2.2 之前,无需为此担心.因此,当您调试基于Net Core 3.0或更高版本的项目时,可以尝试以下方法:

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:

解决方案

1)尝试安装一个名为 Microsoft.AspNetCore的nuget软件包..Mvc.Razor.RuntimeCompilation 放入您的项目.请注意,您的项目基于.Net Core 3.1,因此您应该安装 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 3.1 版本.

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)在启动页面中进行一些更改.在我这边,它是 Startup.cs 文件,然后将它们添加到 ConfigureServices 函数中.

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.

这篇关于Visual Studio Community 2019调试时保存HTML和CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆