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:
Syntax
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
# 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
- Running
dotnet runfrom a folder without a project file, which gives an error about no project found. - Confusing
dotnet build(compiles) withdotnet run(builds and runs). - 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: