After many years of using .NET in real-world projects — from small console utilities to massive enterprise-grade cloud applications — I've realised something: the .NET CLI is one of the most underrated tools in our developer toolkit.
Too often, developers stick to Visual Studio or Rider for everything. Don't get me wrong — I love my IDEs. But over time, I've found that a few well-chosen .NET CLI commands can speed up my workflow, help me debug faster, and make development just a bit more enjoyable.
So, from my previous experience (and probably too many late nights fixing code at 2 AM), here are the .NET CLI commands and tricks I find most useful — plus some personal thoughts on how and when I use them.
Contents
- 1. dotnet new – Start Anything, Anywhere
- 2. dotnet restore – Keep Your Dependencies in Check
- 3. dotnet build – Build Like a Pro
- 4. dotnet run – Instant Execution
- 5. dotnet watch – My Favourite Productivity Booster
- 6. dotnet test – Quick Test Runs Without the IDE
- 7. dotnet format – Keep the Code Clean
- 8. dotnet publish – Ready for Deployment
- 9. dotnet tool – Hidden Power
- 10. dotnet --info – The Doctor's Report
1. dotnet new – Start Anything, Anywhere
If you only remember one command, make it this one.
dotnet new webapi -n MyAwesomeApi
This spins up a new Web API project in seconds. Need a console app?
dotnet new console -n MyTool
My trick: use dotnet new list to see all available templates. Over time, Microsoft and the community have added loads of useful templates — minimal APIs, gRPC services, Blazor apps, worker services, and more.
From my experience, dotnet new is a great way to quickly prototype without clicking through multiple "New Project" wizards.
2. dotnet restore – Keep Your Dependencies in Check
While most modern .NET SDKs restore automatically, I still use this when switching between branches or when the build starts acting "possessed."
dotnet restore
From my experience, running this manually can save time during CI/CD debugging — especially if you suspect a corrupted local cache.
3. dotnet build – Build Like a Pro
Building directly from CLI gives you better insight into what's going on under the hood:
dotnet build
dotnet build -c Release
Tip from my experience: always use -c Release for anything performance-critical — you'll catch certain build-time issues that never show up in Debug.
4. dotnet run – Instant Execution
This one's obvious, but still worth a mention:
dotnet run
dotnet run --project src/MyProject
For quick prototypes, I find this faster than opening the IDE — especially when I'm SSH'd into a build server or working on a Raspberry Pi with .NET installed.
5. dotnet watch – My Favourite Productivity Booster
If there's one feature that changed my development speed, it's dotnet watch.
dotnet watch run
This automatically rebuilds and restarts your app whenever you change the code. Perfect for Web APIs, Blazor, or any service where you want quick feedback.
A little trick: combine it with hot reload (available in newer .NET versions):
dotnet watch run --hot-reload
From my experience, this almost feels like working in a JavaScript environment — fast iteration, minimal waiting.
6. dotnet test – Quick Test Runs Without the IDE
I run tests from CLI more often than from Visual Studio:
dotnet test
dotnet test --filter Category=Integration
This is especially handy in CI/CD pipelines or when you just want to quickly confirm a bug fix before committing.
7. dotnet format – Keep the Code Clean
Nothing kills code reviews faster than formatting arguments.
dotnet format
From my experience, integrating this into your pre-commit hook or CI pipeline keeps everyone happy and your codebase consistent.
8. dotnet publish – Ready for Deployment
When it's time to deploy, I go with:
dotnet publish -c Release -o ./publish
And if I want a self-contained deployment (no need for .NET installed on the server):
dotnet publish -c Release -r win-x64 --self-contained true
From my previous experience, this is especially useful for Docker images — smaller runtime dependencies, fewer surprises.
9. dotnet tool – Hidden Power
The CLI supports global and local tools that can supercharge your workflow:
dotnet tool install -g dotnet-ef
dotnet tool list -g
Some tools I keep installed:
- dotnet-ef – Entity Framework Core migrations
- dotnet-outdated – Checks for outdated NuGet packages
- dotnet-serve – Quick local web server
10. dotnet --info – The Doctor's Report
When debugging environment issues (especially on build servers):
dotnet --info
From my experience, this is the quickest way to confirm SDK versions, runtimes, and environment variables without guessing.
My Closing Thoughts
After many years of using .NET, I've learned that the CLI isn't just a "backup" when you can't use Visual Studio — it's a productivity tool in its own right.
Using these commands, I've:
- Built APIs faster
- Debugged weird dependency issues
- Iterated on features without endless manual rebuilds
- Reduced deployment headaches
If you haven't tried working more from the CLI, give it a shot. It might just save you a few late-night headaches — and maybe even a coffee or two.
Want a printable reference? 📄 Download the .NET CLI Cheat Sheet (PDF)