Project Starters
C# / .NET Project Starter
The dotnet CLI commands to scaffold a console app, web API, or full solution — no Visual Studio wizard required.
C#.NETdotnet CLIweb API
Before you start
Check the SDK (not just the runtime) is installed:
dotnet --version
dotnet --list-sdks
No SDK? Install the current LTS from dotnet.microsoft.com. VS Code with the C# Dev Kit extension is all the editor you need.
Console app (quickest start)
dotnet new console -o MyApp
cd MyApp
dotnet run
Program.cs uses top-level statements — no Main boilerplate, just start typing code.
Web API
dotnet new webapi -o MyApi
cd MyApi
dotnet run
The terminal prints the URL (e.g. http://localhost:5xxx). Hit /weatherforecast for the sample endpoint. Add --use-controllers to the new command if you want classic controller classes instead of minimal APIs.
Real project? Make a solution
dotnet new sln -o MySolution
cd MySolution
dotnet new webapi -o src/MyApi
dotnet new classlib -o src/MyCore
dotnet new xunit -o tests/MyApi.Tests
dotnet sln add src/MyApi src/MyCore tests/MyApi.Tests
dotnet add src/MyApi reference src/MyCore
The commands you'll forget
dotnet watch # run with hot reload
dotnet test # run tests
dotnet add package Serilog.AspNetCore # add a NuGet package
dotnet new list # see every available template
dotnet publish -c Release # deployable build
Common gotchas
- "No project found": you're in the wrong folder — the CLI works relative to where you stand, or pass
--project src/MyApi. - It builds but changes don't show: you ran
dotnet runin another terminal earlier; kill it, or usedotnet watchinstead. - HTTPS certificate warnings on first run:
dotnet dev-certs https --trust(one time per machine).