Skip to main content

.NET CLI Commands

A quick reference for common .NET CLI commands. Each command includes a brief explanation and a copy-ready example.


.NET Version and more​

dotnet --info
dotnet --version
dotnet --list-runtimes
dotnet --list-sdks

Help Command​

dotnet -h
dotnet --help

Display Help for a Command​

dotnet <command> --help

Shows help and usage information for a specific command (replace <command> as needed).


List Available Templates​

dotnet new list

Lists all available project and item templates.


Create a New Console Application​

dotnet new console -n MyApp

Creates a new console application in a folder named MyApp.


Build the Project​

dotnet build

Builds the project in the current directory.


Run the Application​

dotnet run

Runs the application from the current directory.


Restore Dependencies​

dotnet restore

Restores NuGet packages for the project.


Add a NuGet Package​

dotnet add package Newtonsoft.Json

Adds the Newtonsoft.Json package to the project.


List Installed Packages​

dotnet list package

Lists all NuGet packages installed in the project.


Publish the Application​

dotnet publish -c Release -o ./publish

Publishes the application to the ./publish folder in Release configuration.


Run Unit Tests​

dotnet test

Runs all unit tests in the solution or project.


Create a New Solution​

dotnet new sln -n MySolution

Creates a new solution file named MySolution.sln.


Add a Project to a Solution​

dotnet sln add MyApp/MyApp.csproj

Adds the project to the solution file.


Remove a Project from a Solution​

dotnet sln remove MyApp/MyApp.csproj

Removes the project from the solution file.