Difference between Rebuild and Clean + Build in Visual Studio

Rebuild = Clean + Build (usually)

Notable details:

  1. For a multi-project solution, "rebuild solution" does a "clean" followed by a "build" for each project (possibly in parallel). Whereas a "clean solution" followed by a "build solution" first cleans all projects (possibly in parallel) and then builds all projects (possibly in parallel). This difference in sequencing of events can become significant when inter-project dependencies come into play.

  2. All three actions correspond to MSBuild targets. So a project can override the Rebuild action to do something completely different.


Earl is correct that 99% of the time Rebuild = Clean + Build.

But they are not guaranteed to be the same. The 3 actions (rebuild, build, clean) represent different MSBuild targets. Each of which can be overriden by any project file to do custom actions. So it is entirely possible for someone to override rebuild to do several actions before initiating a clean + build (or to remove them entirely).

Very much a corner case but pointing it out due to comment discussions.


Let's define default Rebuild implementation in terms of default Clean and Build implementations:

  1. Per project: Rebuild project = Clean project + Build project.

  2. Per solution: Rebuild sln = foreach project in sln (Clean project + Build project).

Note that due to differences in the order of execution, Rebuild sln is not the same as (Clean sln + Build sln) = (foreach project in sln Clean project) + (foreach project in sln Build project). Also, this "foreach" may execute concurrently, so different tasks are allowed to run concurrently in the two scenarios.

Say you have a sln that contains proj1, proj2, and proj3.

  • Rebuild sln = (Clean proj1 + Build proj1) & (Clean proj2 + Build proj2) & (Clean proj3 + Build proj3)

  • Clean Sln + Build Sln = (Clean proj1 & Clean proj2 & Clean proj3) + (Build proj1 & Build proj2 & Build proj3)

+ means serial, & means concurrent.

So if project dependencies are not configured correctly, there is a chance that when you execute Rebuild sln, some of your projects link to a stale lib. That's because all cleans are not guaranteed to be finished before the first build starts. If you execute Clean sln + Build sln, they will give a link error and let you know that immediately, instead of giving you an app with odd behavior.