是否可以在 Visual Studio 的调试中启用对 .cshtml 的更改?

Is it possible to enable changes to .cshtml in debugging in Visual Studio?

运行 vS21019 中的模板 blazor .Net 5 应用程序,我注意到我在 .cshtml 文件中所做的任何更改都没有显示,而 运行 调试中的应用程序(刷新无效).

可能是因为在执行过程中没有重新编译 razor 内容。

添加了 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation Nuget 包,我认为它可能会有所帮助,但没有效果。

https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0&tabs=visual-studio.

这可能吗?我习惯于进行运行时设计更改,所以我真的很怀念这里没有选项。

您现在在 Blazor 中可以做的最好的事情是使用

从控制台 运行
dotnet watch run debug

还没有real hot reload in blazor,你找到的包是针对 MVC 的,而不是 Blazor。

Make sure to add project settings to tell the watcher what to watch so it does not watch everything. While trying to find resources on this I came upon this thread that adds tons more information and a few more ideas

编辑:这是另一个 VS 设置的屏幕截图,它的作用大致相同 - 我将其保留为 None 通常是因为我想控制构建的时间,但您可以尝试使用它