If you've used both Visual Studio and the dotnet CLI
, you might’ve noticed something curious: the CLI has no “rebuild” command. Yet Visual Studio offers “Rebuild” front and center. So what’s going on under the hood?
🔍 What Rebuild Actually Does
Rebuild in Visual Studio is a combination of two steps, executed for each project in the solution:
-
Clean — Deletes everything in
bin
andobj
, wiping the slate clean. - Build — Compiles the source code from scratch, ignoring any incremental optimizations.
This ensures a full regeneration of binaries, which is useful for resolving weird edge cases, stale references, or flaky builds.
🔄 Isn’t That Just Clean + Build?
Not exactly. The sequencing matters:
- Rebuild executes clean + build sequentially per project, respecting project dependencies.
- Clean All + Build All might clean everything first, but then build in parallel — potentially leading to race conditions in tightly coupled solutions.
This subtle order of operations makes Visual Studio’s rebuild more predictable in certain scenarios.
🧰 What About dotnet CLI?
The CLI focuses on speed via incremental builds. While there’s no native rebuild
, you can mimic the behavior:
dotnet clean
dotnet build
Or script per-project rebuild logic if you need fine control.
✍️ TL;DR
- Visual Studio’s rebuild is a smart clean-build sequence per project.
- dotnet CLI skips this to prioritize speed and modularity.
- Knowing when to use which can save you from hours of puzzling over failed builds.
Top comments (0)