Difference between Build, Rebuild and Clean Solution in Visual Studio?


Difference between Build, Rebuild and Clean Solution in Visual Studio?

Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not. 

The Build Solution option compiles only those project files and components that have changed since the last build. For example consider that you have two projects Proj1 and Proj2 in your solution MySolution. When you compile the solution using Build Solution option after making some changes to Proj1 only Proj1 will be compiled and built but Proj2 will not be compiled since there are no changes to it.

A rebuild removes all the old files (performs a clean) and then builds all the files again.

Rebuild = Clean + Build

Rebuild Solution option builds all project files and components irrespective of the changes made to them.  For example consider that you have two projects Proj1 and Proj2 in your solution MySolution. When you compile the solution using Rebuild Solution option after making some changes to Proj1, both Proj1 and Proj2 will be compiled and built even though there are no changes made to Proj2.

Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.

When you build the project, the dll file are created/modified, but dll created date does not change. But when you Rebuild your project, the dll files are newly created with the current date .

Types of Build:

There are two types of build. A Release build is optimized and it does not contain any additional code that is created to allow you to debug the program in visual studio. A Debug build is not optimized, and it contains additional code that is used when you are debugging your program.