What Is The Difference Between Build, Rebuild And Clean In Visual Studio

We are mostly confused about the difference between build, rebuild, and clean in Visual Studio. Here, I have explained the major differences among all of these.

Here, I am going to explain a very confusing topic, i.e., the difference between Build, Rebuild, and Clean in Visual Studio.
 
Whenever we click on the Build option, the lists will be displayed as below. Here, "GRIDOPERATION" is my project name.
 
What Is The Difference Between Build, Rebuild And Clean In Visual Studio
 

Build Solution

  • It will perform an incremental build. If it doesn't think that it needs to rebuild a project, it won't. It may also use partially built bits of the project if they haven't changed (I don't know how far it takes this).
  •  It compiles the code files (DLL and EXE) which are changed.
It will generate the following message whenever we build any project or the entire solution.
 
What Is The Difference Between Build, Rebuild And Clean In Visual Studio
 

Rebuild Solution

  • It will clean and then build the solution from scratch. It will be ignoring anything it's done before. The difference between this and "Clean, followed by Build" is that Rebuild will clean-then-build each project, one at a time, rather than cleaning all and then building all.
  • It deletes all the compiled files and compiles them again irrespective if the code has changed or not.
It will generate the following message whenever we rebuild any project or entire solutions,
 
What Is The Difference Between Build, Rebuild And Clean In Visual Studio

Clean Solution

  •  It will remove the build artifacts from the previous build. If there are any other files in the build target directories (bin and obj) they may not be removed, but actual build artifacts are. I've seen the behavior for this vary - sometimes deleting fairly thoroughly and sometimes not - but I'll give VS the benefit of the doubt for the moment.
  • It deletes all compiled files (DLL and EXE file).
It will generate the following message whenever we clean any project or entire solutions,
 
What Is The Difference Between Build, Rebuild And Clean In Visual Studio
 
Let it be more clear with the help of the following flowchart.
 
What Is The Difference Between Build, Rebuild And Clean In Visual Studio
 
The difference between Rebuild vs. (Clean + Build), because there seems to be some confusion around this as well:
  • The difference is the way the build and clean sequence happens for every project. Let’s say your solution has two projects, “proj1” and “proj2”. If you do a rebuild it will take “proj1”, clean (delete) the compile files for “proj1” and build it. After that it will take the second project “proj2”, clean compiled files for “proj2” and compile “proj2”.
  • But if you do a “clean” and build”, it will first delete all compiled files for “proj1” and “proj2” and then it will build “proj1” first followed by “proj2”.
What Is The Difference Between Build, Rebuild And Clean In Visual Studio
 
I hope this helps you to better understand the difference between Build, Rebuild, and Clean in Visual Studio.