[英]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
嗨,我是编程新手,正在尝试在 Visual Studio 2019 中运行 C# 项目。当我按下窗口顶部的运行按钮时,该项目运行良好,但问题是我需要它使用
dotnet run
,但我收到错误Couldn't find project to run. Ensure a project exists in C:\directories
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();
目前我正在看一个教程系列,所以我正在尝试使用
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.谢谢你。
Use dotnet run "C:\path\to\my.csproj"
where you replace the path with the actual path to your project file.使用
dotnet run "C:\path\to\my.csproj"
将路径替换为项目文件的实际路径。
Are you running dotnet run
in the directory of the application?你是在应用程序的目录下运行
dotnet run
吗? Do cd C:\path\
then dotnet run "test.exe"
.执行
cd C:\path\
然后dotnet run "test.exe"
。 Or just do dotnet run "C:\path\test.exe"
.或者只是做
dotnet run "C:\path\test.exe"
。 Obviously change C:\path
to your actual path.显然将
C:\path
更改为您的实际路径。
1.Please make sure your project is .NET Core 2.x or later versions. 1.请确保您的项目是 .NET Core 2.x 或更高版本。
2.Discover the storage location of ConsoleApp1.csproj. 2.发现ConsoleApp1.csproj的存放位置。
(Your project storage location is C:\Users\path\source\repos\ConsoleApp1\ConsoleApp1) (你的项目存放位置是C:\Users\path\source\repos\ConsoleApp1\ConsoleApp1)
According to your description, I built a similar project.根据您的描述,我建立了一个类似的项目。 The execution process is as follows:
执行过程如下:
Navigate to you project folder, create the project: dotnet new console
It will create .csproj
file and others.导航到项目文件夹,创建项目:
dotnet new console
它将创建.csproj
文件和其他文件。 Then just run dotnet run
.然后运行
dotnet run
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.