Home » dotnet » dotnet run – dotnet : Couldn’t find a project to run. Ensure …

dotnet run – dotnet : Couldn’t find a project to run. Ensure …

By Emily

I needed to test a .Net core project as if it was deployed to production, so in order to do that I needed to set the environment variable to production. According to these docs that describe how to manage multiple environments in an ASP.Net Core application, you should be able to that by using a flag with dotnet run, typing this at the cmd prompt:

set ASPNETCORE_ENVIRONMENT=Production
dotnet run --no-launch-profile

However on doing so I got an error message which says something like:

dotnet : Couldn’t find a project to run. Ensure a project exists in C:\Users\projects\Repos\WebAPI, or pass the path to the project using –project.

Using dotnet run –project

As the instructions in the message say, typing this works:

dotnet run --project name-of-project-here

If you aren’t sure of the name of your project, right click on the project name in the solution explorer, and select Properties (it’s the last option in the long list on my PC).

When the Properties window opens you can copy the value from the Assembly name textbox and use that in the command.

Using the dotnet run command with a dll

The dotnet run command is used in the context of projects, so if you are trying to run an application dll instead you can simply type this instead:

dotnet yourprojectname.dll

You may also be interested in: