Back to results for “Commands”
.NET › .NET CLI, SDK & Project Structure (csproj)

What is the dotnet CLI, and what are some of its most commonly used commands?

Beginner

Answer

The dotnet CLI is the cross-platform command-line interface for creating, building, running, testing, and publishing .NET projects. Common commands include `dotnet new` (scaffold a project), `dotnet build`, `dotnet run`, `dotnet test`, `dotnet publish`, `dotnet add package`, and `dotnet restore`.
dotnet new webapi -n MyApi
cd MyApi
dotnet restore
dotnet build
dotnet run
Real-world example A developer onboarding to a new project runs `dotnet restore && dotnet build && dotnet test` as a single sequence to verify their environment is set up correctly before writing any code.

Common follow-ups: How does dotnet new differ from Visual Studio's project wizard?;What does dotnet restore actually do under the hood?