The dotnet CLI is your command-line interface to create, build, test, and publish .NET projects—like npm plus a compiler plus project templates in one tool.
Essential commands
dotnet --version— installed SDK versiondotnet new web -n MySite— MVC/Razor web app templatedotnet new webapi -n MyApi— Web API templatedotnet restore— fetch NuGet packagesdotnet build— compiledotnet run— build and run (Kestrel starts)dotnet watch run— hot reload during developmentdotnet ef migrations add Initial— EF Core migrations (with tools installed)
Typical first project
dotnet new web -n Bookstore
cd Bookstore
dotnet run
# Browse https://localhost:5xxx
Important interview questions and answers
- Q: dotnet new vs Visual Studio?
A: Same templates—CLI is CI-friendly and cross-platform; VS adds GUI and debuggers. - Q: Where are templates defined?
A: SDK ships default templates; install more withdotnet new install.
Self-check
- Which command starts the dev server after scaffolding?
- What does dotnet restore do?