Skip to the workspace
Pebellslearn by building
C# and .NET Basics  ›  Lesson

The .NET CLI — One Command for Everything

.NET CLI 12 minThe dotnet command creates, restores, builds, runs, tests and publishes projects, so every task is a verb after the word dotnet.

aspnet core / The .NET CLI — One Command for Everything

Explore each scene at your own pace.

01 · The rule

The rule

The .NET CLI — One Command for Everything

You do not need a heavy IDE to build ReadingRoom. Every task — create a project, add a package, build, run, test, publish — is one command in a terminal. The same commands run on your laptop and in a CI pipeline, which is exactly why they are worth learning.

The rule

dotnet plus a verb: new, add, build, run, test, publish.

The command is always dotnet <verb> [options]. The verbs you will type most:

dotnet new webapi -n ReadingRoom.Api   # create a project from a template
dotnet add package Dapper              # add a NuGet package
dotnet build                           # compile (restores packages first)
dotnet run                             # build and start the app
dotnet watch                           # run and reload on every save
dotnet test                            # build and run the tests
dotnet publish -c Release              # produce files ready to deploy

dotnet new list shows the templates: web (an empty site), webapi, mvc, razor (Razor Pages), blazor, classlib, xunit and more. A solution (.sln) groups several projects so one command builds them all.

Packages come from NuGet, .NET's package registry. dotnet add package writes a <PackageReference> into the .csproj; the next build downloads it. You rarely type dotnet restore yourself — build, run and test restore first.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.