dotnet watch reports back 'can't find a project to run' dispite being in the "C:\Users\######\mslearn-create-razor-pages-aspnet-core" directory

cademon bishop 0 Reputation points
2024-10-26T12:57:08.9466667+00:00

Im in the cmd but cant get dotnet watch or even dotnet watch run to work. dotnet new page works just fine, wondering it its something with this module in the Build web apps with ASP.NET Core for beginners

This question is related to the following Learning Module

Community Center | Not monitored
{count} votes

1 answer

Sort by: Most helpful
  1. Pradeep M 9,775 Reputation points Microsoft External Staff Volunteer Moderator
    2024-10-28T06:42:33.8+00:00

    Hi cademon bishop,

    The error message “can't find a project to run” generally means dotnet watch is unable to locate the .csproj file for the project. We have verified everything on our end, and all appears to be in order. However, here are some additional steps you can try. 

    First, confirm you’re in the correct directory where the ContosoPizza.csproj file is located. This should be C:\Users######\mslearn-create-razor-pages-aspnet-core. If you're already in the correct directory and still seeing the error, you might try explicitly specifying the project file by running dotnet watch --project ContosoPizza.csproj. This tells dotnet watch exactly which project to monitor and run. 

    Please also ensure that the correct .NET SDK version is installed. Since this project uses .NET 7.0, you can check that version by running dotnet --list-sdks in the command prompt. If .NET 7.0 is missing, you’ll need to install it, or alternatively, you can adjust the project to target .NET 8.0 by updating the <TargetFramework> in the .csproj file from net7.0 to net8.0. 

    Finally, we have included a screenshot for reference:
    User's image

    Please feel free to contact us if you have any additional questions.    

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.