Build Rebuild and Clean in Visual Studio

Essential Difference between Build Rebuild and Clean in Visual Studio

In this post, we will be listing down the difference between build rebuild and clean in visual studio.

We have encountered this topic many times among freshers and a couple of year’s experienced professionals as well.

Introduction

Some programmers have made this a habit of doing clean + build every time they change code without knowing the significance of it.

Some of them always prefer to do a rebuild every time the change or modify some parts of the code.

With the help of this post, we are trying to list out the significance of each – build rebuild and clean options and make readers understand when to use them.

Build Solution

The build solution will always perform an incremental build. i.e It will only build those files which have changed. The files which aren’t modified or changed won’t be built.

Rebuild Solution

Rebuild solution will delete all the compiled files(DLLs and EXE) and will perform build from scratch irrespective of whether the files are modified or not. It is a combination of Clean + Build.

Clean Solution

The clean solution will delete all the compiled files(DLLs and EXE) from bin/obj directories.

Difference Build Rebuild and Clean in Visual Studio

The difference lies in the way the build and clean happens for every project.

For example, if the solution has two projects – Project 1 & Project 2 and you do a rebuild, it will take Project 1, clean (delete) the compiled files for Project 1, and build it. After that, it will take Project 2, clean the files for Project 2, and build it.

On the other hand, if you do a clean and build, it will first clean (delete) all compiled files(DLLs and EXE) for both the projects – Project 1 & Project 2 and then it will build Project 1 first, followed by Project 2.

Diagrammatic representation:

Difference between build rebuild and clean in visual studio.

Difference between Build Rebuild and Clean in Visual Studio

We hope the difference between build rebuild and clean is clear. If you have any doubts related to the post, please mention in comments below.

Further Reading: You may have a look at these articles below:

What do you think?

Dear Reader,
If you have any questions or suggestions please feel free to email us or put your thoughts as comments below. We would love to hear from you. If you found this post or article useful then please share along with your friends and help them to learn.

Happy Coding!

Share with your friends:

3 thoughts on “Essential Difference between Build Rebuild and Clean in Visual Studio”

  1. Does the order of cleaning the project and building it again has any importance or is it right to say that rebuild and, clean and build are almost same except the fact that order of performing task is different?

    1. Re-build deletes all compiled files and Compiles them again regardless of whether or not the code has changed. The build will only compile the DLLs where we have a code change.

      1. I think that Kumar asket if there can be differences between:
        * clean all + build all
        * clean prj1 + build prj1 + clean prj2 + build prj2 …
        In both there are not compiled files (after clean), so VS compiles all files again regardless of whether or not the code has changed.
        Tnk

Leave a Comment

Your email address will not be published. Required fields are marked *