Search code examples
c#visual-studiovisual-studio-2019

Visual Studio C#: dotnet run Couldn't find project to run


Hi I'm new to programming and am trying to run a C# project in Visual Studio 2019. The project runs fine when I press the run button at the top of the window but the issue is I need it to run using dotnet run but I get the error Couldn't find project to run. Ensure a project exists in C:\directories

I have to get it to run this way because I am trying to create a program that can take user input. Currently I'm watching a tutorial series so I am trying to use Console.Readline();

I can provide more information if necessary, I am new to programming and am not exactly sure what information someone may need to help me.

Thank you.


Solution

  • 1.Please make sure your project is .NET Core 2.x or later versions. here
    2.Discover the storage location of ConsoleApp1.csproj.

    (Your project storage location is C:\Users\path\source\repos\ConsoleApp1\ConsoleApp1)

    According to your description, I built a similar project. The execution process is as follows: here