我已经弄清楚了,只有在不使用调试时运行项目才能正常工作。
按Ctrl + F5(热重载可用),按F5(不可用)
如果Visual Studio突然停止工作,请尝试重新启动它。
我可以确认,当在运行 Visual Studio 2022 和 .NET 6 时,The Thirsty Ape 建议的方法是可行的。
dotnet watch --project .\your-project-name-here.csproj
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
最后,在进行代码更改之后:
watch : Hot reload of changes succeeded.
看起来热重载只在特定的配置下工作:
我已经在Visual Studio v17.2.2中测试过(虽然v17.1.2也应该足够)
还有一件要检查的事情是,如果像我一样依赖“文件保存时热重载”,请确保它实际上是开启的。
它可以在火焰图标的菜单中找到。
我不知道怎么做的,成功关闭了它,并且甚至没有意识到有一个热重载按钮。
dotnet watch --project .\my-wasm.csproj
。GitHub 问题 - The Thirsty Ape