简体   繁体   中英

Blazor dotnet watch run

I have setup a Blazor WebAssembly application using Visual Studio Code and .NET 3.1.1. It has an ASP.NET Core host. I am attempting to automatically update code on both the server and the client at the same time using dotnet watch run but I am unable to do so. I have tried opening two separate command lines and running the command on both the client and server but it only allows me to run on one at a time. I have also attempted to add the following code to my Server .csproj file:

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

but when I run dotnet watch run in the server folder in command line and make any changes, I get this error:

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]

Also when I make any changes to the server project it does not update unless I re-run the program. It will recognize changes to the Client folder but throws that error above.

If I run dotnet watch run on the Client folder it works fine.

Any recommendations on how to successfully run dotnet watch run on both client and server at the same time without getting this error?

Unfortunately, there is no option to use dotnet watch run with Blazor for the moment.

See the documentation :

For now, you can't:

  • ...
  • Automatically rebuild the backend Server app of a hosted Blazor WebAssembly solution during debugging, for example by running the app with dotnet watch run .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM