Skip to content

Instantly share code, notes, and snippets.

@BekBrace
Last active May 13, 2026 04:00
Show Gist options
  • Select an option

  • Save BekBrace/80846d74d6046d3f63b100f291d6603f to your computer and use it in GitHub Desktop.

Select an option

Save BekBrace/80846d74d6046d3f63b100f291d6603f to your computer and use it in GitHub Desktop.
DOTNET list of commands

🧰 Essential .NET CLI Commands (2026)

The .NET CLI (dotnet) is the command-line interface used to create, build, run, test, and manage .NET applications.

BBrace Tip:

This is the central command tool for the entire .NET ecosystem - remember that.

It is broader than Cargo in Rust or NPM in JavaScript.


πŸ” Environment & SDK Information

Check installed .NET version

dotnet --version

Shows the currently active SDK version.

Example:

9.0.100

Show detailed .NET information

dotnet --info

Displays:

  • installed SDKs
  • runtimes
  • operating system
  • architecture
  • environment paths

List installed SDKs

dotnet --list-sdks

List installed runtimes

dotnet --list-runtimes

πŸ“ Project Creation Commands

Create a new console application

dotnet new console

Creates a basic CLI app.


Create project inside a specific folder

dotnet new console -o MyApp

-o means:

output directory

This creates:

MyApp/

and places the project there.


Enter the project directory

cd MyApp

Create a web API project

dotnet new webapi

Used for backend/API development.


Create an MVC web app

dotnet new mvc

Create a class library

dotnet new classlib

Useful for reusable libraries/packages.


List all project templates

dotnet new list

Shows available templates:

  • console
  • webapi
  • mvc
  • blazor
  • xunit
  • maui etc.

▢️ Running Applications

Run the current project

dotnet run

This:

  1. builds the project
  2. launches the executable

Run without rebuilding

dotnet run --no-build

Useful for faster iteration.


πŸ”¨ Building Projects

Build the project

dotnet build

Compiles source code into:

  • DLLs
  • EXEs
  • intermediate artifacts

Build Release version

dotnet build -c Release

-c means:

configuration

Usually:

  • Debug
  • Release

πŸ“¦ Publishing Applications

Publish app for deployment

dotnet publish

Creates deployable output.


Publish optimized Release build

dotnet publish -c Release

Publish self-contained executable

dotnet publish -r win-x64 --self-contained true

This bundles:

  • your app
  • .NET runtime

into a standalone executable.


πŸ“„ Package Management (NuGet)

Add package

dotnet add package Newtonsoft.Json

Installs external libraries from NuGet.


Remove package

dotnet remove package Newtonsoft.Json

Restore dependencies

dotnet restore

Downloads missing packages.


πŸ§ͺ Testing Commands

Create test project

dotnet new xunit

Creates unit testing project.


Run tests

dotnet test

🧹 Cleaning Commands

Clean build artifacts

dotnet clean

Removes:

  • /bin
  • /obj

generated files.


🧠 Solution Management

Create solution file

dotnet new sln

Add project to solution

dotnet sln add MyApp.csproj

⚑ Interactive / Scripting Tools


🟣 C# Interactive (REPL)

Launch C# interactive shell

csi

REPL = Read Eval Print Loop

Lets you execute C# code interactively.

Example:

> 5 + 5
10

⚠️ csi may require:

  • Visual Studio
  • Roslyn tools
  • separate installation

depending on environment.


🟒 dotnet-script (community tool)

A very popular scripting tool.

Install:

dotnet tool install -g dotnet-script

Run script:

dotnet script hello.csx

Interactive mode:

dotnet script

Useful for:

  • quick experiments
  • automation
  • scripting
  • teaching

🌍 Global Tool Management

Install global CLI tool

dotnet tool install -g <tool-name>

List installed tools

dotnet tool list -g

Update tool

dotnet tool update -g <tool-name>

🧩 Useful Real-World Workflow

Typical developer flow:

dotnet new console -o LibraryApp
cd LibraryApp
dotnet run

Then later:

dotnet add package Newtonsoft.Json
dotnet build
dotnet publish -c Release

🎯 Most Important Beginner Commands

If you're new to C#, focus first on:

Command Purpose
dotnet --version Check SDK
dotnet new console Create app
dotnet run Run app
dotnet build Compile app
dotnet add package Install libraries
dotnet restore Download dependencies
dotnet publish Create deployable app
csi Interactive C# shell
dotnet script Run scripts interactively
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment