Search code examples
c#.net-5blazor-webassembly

Getting errors when i try to run dot net watch run on my Blazor project on .net5


Hi just wanted to know if I have to do something differently.

as shown on tutorial on package manager console

I do pm > dir

then I get



Mode                 LastWriteTime         Length Name                                                                   
----                 -------------         ------ ----                                                                   
d-----        02/08/2021     21:41                BattlesBlazor                                                          
-a----        02/08/2021     22:08           2581 .gitattributes                                                         
-a----        02/08/2021     22:08           6585 .gitignore                                                             
-a----        03/08/2021     10:28           2194 BattlesBlazor.sln    

then when I run dotnet watch run I am getting the following error

dotnet : watch : Could not find a MSBuild project file in 'C:\Users\Desktop\Desktop\Deskto 2\DevProjects\BattlesBlazor'. 
Specify which project to use with the --project option.
At line:1 char:1
+ dotnet watch run
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (watch : Could n...project option.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

not sure what is actually happening, any advice would be appreciated, thanks.

Edit: The contents of the project


Solution

  • It is possible to build a solution, this is why the following command works :

    dotnet build
    

    But it isn't possible to run a solution, because a solution can have multiple executable projects, or even none.

    I don't think it's possible to watch a wasm project. But you can watch the server part.

    To run, you can specify the project file like :

    # Start the client without blocking the package console manager
    start "" dotnet run --project BattlesBlazor\Client\BattlesBlazor.Client.csproj
    
    # Start with diagnostic the server
    dotnet watch run --project BattlesBlazor\Server\BattlesBlazor.Server.csproj