Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Build solution vs. Rebuild solution vs. Clean solution Menu

4.89/5 (44 votes)
22 Jul 2013CPOL2 min read 119.2K  
I had a very vague idea, but I wanted to be sure about the exact differences between them.

I am not aware of a single day in my life when I have not clicked on the Build, Rebuild, or Clean menu of Visual Studio. Even though I use it on a daily basis or sometimes even on a minute to minute basis when my keyboard is high on coding, I am still not clear what exactly each one of these menus does. I had a very vague idea, but I wanted to be sure about the exact differences between them.

When I hunted for the differences what came out was surprising, below goes a detailed explanation of the same.

Image 1

Build solution menu

This will perform an incremental build. In other words it will only build code files which have changed. If they have not changed those files will not be touched.

Rebuild solution menu

This will delete all currently compiled files (i.e., exe and DLLs) and will build everything from scratch, irrespective of if there is code change in the file or not.

Image 2

Clean solution menu

This menu will delete all compiled files (i.e., EXE’s and DLL’s) from the bin/obj directory.

Now if you read the above three points I have discussed, you can conclude that:

Rebuild = Clean + Build

So the next question would be if you do a Rebuild and if you do Clean + Build, what is the difference?

The difference is the way the build and clean sequence happens for every project. Let’s say if your solution has two projects, proj1 and proj2. If you do a rebuild it will take proj1, clean (delete) the compiled files for proj1, and build it. After that it will take the second project proj2, clean the 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.

The below image explains the same in a more visual format.

Image 3

Below is a simple YouTube video which demonstrates the difference between these entities. 

Image 4

For Further reading do watch  the below interview preparation videos and step by step video series.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)