dotnet core::Unable to run your project. Ensure you have a runnable project type and ensure 'dotnet run' supports this project
Asked Answered
A

5

9

I have been running into an error lately trying to run some code with dotnetcore. When I try to run the project in the console (dotnet run), I get this error.

Unable to run your project. Ensure you have a runnable project type and ensure 'dotnet run' supports this project. A runnable project should target a runnable TFM (for instance, netcoreapp2.0) and have OutputType 'Exe'. The current OutputType is 'Exe'.

FYI, here are entries in the .csproj file

enter image description here

Also, I have the following skds and runtimes installed. Yet, whatever TargetFramework I set in the .csproj, I get the same error.

enter image description here

Apparently answered 11/8, 2020 at 1:30 Comment(8)
Are you running the command from the directory of the .csproj file?Fraktur
@Fraktur Yes I am. Also, the build (dotnet build) runs successfully. Thanks.Apparently
github.com/andrewlock/NetEscapades.Templates/issues/1 Have you tried this?Rutharuthann
dotnet run -f netcoreapp2.1Rutharuthann
Hi @Manish. Thanks for your reply. Yes, I have tried that, the problem persists.Apparently
have you created this project using visual studio?Rutharuthann
Hi @Manish. Yes, and that was the problem ! Thanks for your comment !Apparently
@Fraktur I was not. Turns out dotnet build <projectdirname> works, but dotnet run <projectdirname> won't work from there.Perlite
A
3

I found a solution to my issue.

The problem was that I had created the project using Visual studio. Hence, the .csproj project file was not in a suitable format for dotnet core.

To solve the issue, I created an empty project with dotnet core:

mkdir myNewApp
cd myNewApp
dotnet new console

Then, I added to the project all the source files I had created with visual studio by simply copying and pasting them in the app folder. I grouped them in the single directory 'src'. At build, dotnet core automatically finds these files and builds the project with them.

Apparently answered 23/8, 2020 at 6:8 Comment(1)
I was trying to run the project from PowerShell and also building/developing/running from VisualStudio and this was the issue for me. I think OP would most likely have something similar.Torrid
S
2

Mine is an Azure Durable function. I got the following error when I try to run it with dotnet cli using the command dotnet run.

Unable to run your project. Ensure you have a runnable project type and ensure 'dotnet run' supports this project. A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'. The current OutputType is 'Library'.

The solution is simple. You cannot use dotnet cli for this. Instead You need to run using the command func start as explained here.

And of course you need to install the azure function tools.

Scrofula answered 8/2, 2022 at 10:15 Comment(0)
H
2

Most probably it is do something with the version you are trying, in my case, I was using .nerstandard 2.0 which was wrong and I changed it to net5.0 and I was able to run successfully. It looks like this now -

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
Hind answered 19/6, 2022 at 14:48 Comment(1)
This is all I needed to get dotnet run to workInstill
R
0

I have experienced the same problem that the project refuses to create an EXE file. It was showing to compile a DLL, yet required an EXE to run.

I was using dotnet core and VS-Code and didnt suspect anything until I tried to rename the project folder to start another with the same name. What I got was greyed out folder/file names for some time about 10 sec with no name change.

Only then I realized: though I deleted "bin" folder, there was an instance of the project somehow running alive but hidden (should have prevented me deleting folder otherwise) and prevents any new EXE to be written.

Solution you might ask, simple: just close/restart IDE completely. Any program spawned with it will be terminated. trying to close/terminate terminals do not work.

Rexanna answered 17/10, 2020 at 12:50 Comment(0)
T
-4

Open CMD.EXE and run the following commands:

dotnet new console -o myApp
cd myApp
dotnet run

It works for me.

https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/run

Tropic answered 19/1, 2021 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.