← Back to C# Course | Chapter 1: Setup & Basics | Lesson 4 of 7

The dotnet CLI

The dotnet command is a helper you talk to in the terminal that can start new projects, build them, and run them. It is like a butler who does the setup chores while you focus on your ideas.

In this page:

  1. The dotnet CLI
Syntax
csharp
dotnet new console -n ProjectName   // create a project
dotnet build                        // compile
dotnet run                          // build and run

The dotnet CLI

The dotnet command-line tool creates, builds, and runs C# projects without needing an IDE.

dotnet new console scaffolds a runnable console project, dotnet build compiles it, and dotnet run builds and executes it in one step. This tool is the standard entry point for .NET development on any platform.

Note: dotnet run rebuilds automatically if source files changed since the last build.

Example: The dotnet CLI

bash
# Create a new console project in the current folder
dotnet new console -o HelloApp
cd HelloApp

# Build without running
dotnet build

# Build and run in one step
dotnet run

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Running dotnet run from a folder without a project file, which gives an error about no project found.
  2. Confusing dotnet build (compiles) with dotnet run (builds and runs).
  3. Creating a project inside another project's folder, which can make the build pick up the wrong files.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.