Difference between build rebuild and clean in visual studio

Difference between build rebuild and clean in visual studio

Howdy Reader,

I have encountered this topic many a times among freshers and a couple of year’s experienced professionals as well. 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 part of code.

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

Difference between build rebuild and clean in visual studio

Difference between build rebuild and clean in visual studio

Build Solution:

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 build.

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:

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

The Difference:

Clean + Build = Rebuild Click To Tweet

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

I hope the difference between build rebuild and clean is clear. If you have any doubts related to the post, please mention it in comments below. We have got few ASP.NET related articles for you which are just a click away here.

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 Learning :)

  • Mayank Shori

    Nice….Keep sharing buddy!!!

  • Awesome !! Nice Info !!

  • Great article, concise and clear explanation. Thank you!

  • Amit Ghute

    I like this information. Great work. 🙂

  • My NomDeplumes

    Great! But… Why would you do one over the other and when? Please use real-world scenarios.

    • @mynomdeplumes:disqus You can use them as per your requirement.

      Build solution: Only build those files which have changed.
      Rebuild: Delete all the compiled files(DLLs and EXE) and will perform build from scratch irrespective of whether the files are modified or not
      Clean solution: Delete all the compiled files(DLLs and EXE).

      So, if you want to perform a build from scratch by deleting existing files (DLLs and EXE) then go with Rebuild.

      If you want to simply build the files that have changed and don’t want any other files (DLLs and EXE). Then clean the solution and do a Build.

      Hope it’s clear now!

  • I thought Rebuild cleaned ALL files first, then begin building project by project, not Clean 1/Build 1/Clean 2/Build 2/etc… Interesting.