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
dotnetplus 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 deploydotnet 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.
The shortcut
Say what you want in plain words, then find the verb: make something → new; bring in something → add; check it compiles → build; see it working → run; prove it works → test; ship it → publish.
Make the solution
dotnet new sln -n ReadingRoomcreates the file that holds the projects.
The trap: running dotnet run in a folder with no project, or with a solution but no --project. The CLI needs to know which project to start.
Drills
Answer fast — trust the rule.
Which command adds the Dapper package to the current project?
You want the API to restart every time you save a file. Which command?
Where does dotnet add package record the dependency?
Which template gives you an empty web app with almost nothing in it?
Remember
dotnetplus a verb: new, add, build, run, test, publish.- Say the goal in plain words, then pick the verb.
- Build, run and test restore packages for you.
