【问题标题】:Blazor dotnet watch runBlazor dotnet 观看运行
【发布时间】:2020-11-05 03:54:47
【问题描述】:

我已经使用 Visual Studio Code 和 .NET 3.1.1 设置了 Blazor WebAssembly 应用程序。它有一个 ASP.NET Core 主机。 我正在尝试使用dotnet watch run 同时自动更新服务器和客户端上的代码,但我无法这样做。我尝试打开两个单独的命令行并在客户端和服务器上运行该命令,但它只允许我一次运行一个。我还尝试将以下代码添加到我的 Server .csproj 文件中:

<ItemGroup>
    <Watch Include="..\Client\**\*.razor" />
</ItemGroup>

但是当我在命令行的服务器文件夹中运行dotnet watch run 并进行任何更改时,我得到了这个错误:

C:\Program Files\dotnet\sdk\3.1.403\Microsoft.Common.CurrentVersion.targets(4187,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp3.1\BlazorBattles.Server.dll" to "bin\Debug\netcoreapp3.1\BlazorBattles.Server.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Users\dbandara\Development\dotnet\Tutorials\BlazorBattles\BlazorBattles\Server\bin\Debug\netcoreapp3.1\BlazorBattles.Server.dll' because it is being used by another process.  [C:\Users\dbandara\Development\dotnet\Tutorials\BlazorBattles\BlazorBattles\Server\BlazorBattles.Server.csproj]

此外,当我对服务器项目进行任何更改时,除非我重新运行程序,否则它不会更新。它会识别对 Client 文件夹的更改,但会在上面抛出该错误。

如果我在客户端文件夹上运行dotnet watch run,它可以正常工作。

有关如何在客户端和服务器上同时成功运行 dotnet watch 而不出现此错误的任何建议?

【问题讨论】:

    标签: c# asp.net blazor blazor-webassembly


    【解决方案1】:

    很遗憾,目前没有将 dotnet watch run 与 Blazor 一起使用的选项。

    the documentation:

    目前,您不能:

    • ...
    • 在调试期间自动重建托管 Blazor WebAssembly 解决方案的后端服务器应用程序,例如通过 dotnet watch run 运行应用程序

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多