How to run a C# .Net app from the terminal

NicolasBrondinBernard

Author
@NicolasBrondinBernard

Need to run your application without using Visual Studio? Here are the two commands you'll need!

Article published on 09/12/2022, last updated on 10/08/2026

Usually, to launch your .Net C# project, you open your favorite IDE (say Visual Studio or Rider), but sometimes you may need to compile and run your application directly from a terminal!

And actually, the task is rather simple! As soon as DotNet is installed, you'll only need a few command lines.

Compile

$> cd MyProject
$> dotnet build -c Debug

** The -c parameter denotes the compilation mode, it can be equal to "Debug" or "Release", but it's up to you to see which version you want to test. **

The compilation should create an executable in the subfolder: "./bin/Debug/net[version]/MyProject.exe"

Run

To run the project, you can use the following command:

$> dotnet run

You can also go run the .exe file manually available under ./bin/Debug/net[version].0/MyDotNetProject.exe

Publish

To publish your application, you can also use the "publish" command, like this:

$> dotnet publish

The difference between the "build" and "publish" commands lies in the fact that with publish, all the files necessary for the application to run will be included in the compilation folder (/bin)!


Tadas Sar sur Unsplash

Finished reading this article?
Our complete courses
Take it to the next level with our courses!

Complete courses, exercises and certificates to really learn programming!

4.8 average rating

Comments (0)

to leave a comment

No comments yet