我创建了一个这样的项目:
dotnet new blazorwasm -f net6.0
我正在与一起运行该项目
dotnet watch run
每当我保存了应该触发重建的东西时,就会识别出变化,但什么都没发生。我只得到以下信息,没有更多:
watch : File changed: /Path/to/File.example.
它运行了一段时间,然后突然停了下来。
全输出:
watch : Project supports hot reload and was configured to run with the default run-command. Watching with hot-reload
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
watch : Building...
watch : Started '/usr/local/share/dotnet/dotnet' '' with process id 3155
Determining projects to restore...
All projects are up-to-date for restore.
waveshape -> /Users/example/Projects/waveshape/bin/Debug/net6.0/waveshape.dll
waveshape (Blazor output) -> /Users/example/Projects/waveshape/bin/Debug/net6.0/wwwroot
watch : Process id 3155 ran for 3605ms
watch : Running MSBuild target 'GenerateWatchList' on '/Users/example/Projects/waveshape/waveshape.csproj'
watch : Started '/usr/local/share/dotnet/dotnet' '' with process id 3164
watch : Process id 3164 ran for 557ms
watch : Watching 28 file(s) for changes
watch : dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
watch : Configuring the app to use browser-refresh middleware.
watch : Refresh server running at wss://localhost:61209,ws://localhost:61210.
watch : HotReloadProfile: BlazorWebAssembly.
watch : Started 'dotnet' '"/Users/example/.nuget/packages/microsoft.aspnetcore.components.webassembly.devserver/6.0.1/build/../tools/blazor-devserver.dll" --applicationpath "/Users/example/Projects/waveshape/bin/Debug/net6.0/waveshape.dll"' with process id 3173
watch : Running dotnet with the following arguments: run
watch : Started
watch : Waiting for a browser to connect
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7081
watch : Launching browser.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5236
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /Users/example/Projects/waveshape
watch : File changed: /Users/example/Projects/waveshape/Pages/Index.razor.
我遇到了这个问题,当http端口为"错误";。我不知道为什么是";错误";,但端口5220我有完全相同的问题,但当我改为5180时,它就工作了。
端口更改必须在launchSettings.json
文件中完成。
有人创建并发布,但尚未得到回应。
尝试
dotnet watch --project .ProjectName.csproj -v
dotnet watch --project . -v
如果您看到
watch : Hot reload capabilities: Baseline.
它应该能正常工作。
这是一种解决方法,因为热重新加载存在问题。其他人也有问题——https://github.com/dotnet/aspnetcore/issues/38036