Visual studio Build VS Rebuild Vs Clean (c# interview questions with answers )


As a Visual Studio Developer i am not aware of a single day in my life when i have not clicked on build Rebuild or Clean Solution menu i am sure that many developer’s are aware of difference between these menus but believe me many developers are not aware of it so in this video we will try to understand what exactly is the differences between build solution rebuild solution and clean solution so let’s first start with the differences between build solution and rebuild solution build solution will perform on incremental build in other words it will only build code file which have change if they have not changed it will not build them so if codes file have change then build solution will actually go and build only those file rebuild solution will build all the code files irrespective if they change or not changed while the rebuild happens it will first go and clean all the compiled file that means will go and delete all your current compiled exc and dls and then it will build everything from scratch irrespective it the code has changed or not so let’s try to demonstrate build solution and rebuild solution you can see that we have very simple solution here and in this solution i have a class library and i have very simple console application and if you see this class library and the console application they were build the last build was on this time so you can see here date modified the top folder actually shows the class library dll which was build on 7/22/2013 at 7:22 AM and you can see the console application was also build on the same time 7/22/2013 7:22 AM now what i will do is let me go ahead and only modify console application so let’s say some developer comes and he put some code over here and let me go and only build this ok i am not clicking on rebuild and clean i am just going and building this so in other words what should happen now is as per the fundamentals what we spoke previously as soon as click on build here it will only go and build the console application and it will not build the class library so let me go and click on build here and let me quickly go back to the folders view now if you see the date modified of both of this libraries you will see that the class library date modified and the time is same if you remember it was 7:22 AM 7/22 that is the same thing and if you see this console application50.exc it is now 7/22/2013 7:34 AM so the 7:22 AM is now change to 7:34 AM in other words the build solution only went ahead and it only compiled this console application because the code had only change in the console application now let’s say if i go and click on rebuild now let see what happen now if you go back here again you can now see that both the files have been modified you can see here class library1.dll is now 7:38 AM as well as ConsoleApplication50.exc is now 7:38 AM so irrespective of code file has change or not changed the rebuild solution first goes and delete all your dll and exc that means your compile files and then he goes and build same again now the next thing is what exactly is this clean solution the clean solution menu actually just goes and deletes all your compile files if you click on this screen solution here and if you go and see your folder view you can see that all the compile files have gone off so you can see all the dll have gone off from the class library1 folder and you can also see that all the exc have gone off from the debug folder you can see that there are some manifest file another files here because those are not compiled file so they are there but the compile file that is the dll and exc have been deleted so the build solution builds only the code change rebuild solution will go and delete all your compiled files and rebuild all your file irrespective the code has changed not while clean solution just goes and delete yours compiled file so whatever things we have discussed till now what we can conclude is that rebuild is nothing but it is clean + build now the next questions is then why do we have this rebuild option in other words i can just click on first clean and than i can click on build so what is the difference between rebuild and what is different between doing a clean and then a build the differences is the way build and clean sequence happens for the every project so now let’s say if you have a solution and it has two project let’s say project 1 and project 2 now if you do a rebuild what it will do is it will take project by project it will first go and clean project 1, build project 1, than it will be take the next project it will go and clean project 2 and build project 2 but if you do a clean and build it will first go and delete all the compiled file so project 1 and project 2 and then do a build of all project 1 and project 2 so the differences is the way the sequences of build and clean happens in rebuild it goes project wise while in clean + build it first goes and delete everyone delete all the compile files and then goes and builds the complete project So i hope that you enjoyed this video in this video we will trying to understand what exactly is a difference between build, rebuild and clean solution. THANK YOU SO MUCH πŸ™‚

14 thoughts on “Visual studio Build VS Rebuild Vs Clean (c# interview questions with answers )

  1. But if the difference between Rebuild and Clean + Build its only the order of the Clean/Build, there is still no much difference right? Or does this order change anything?

  2. I think most of the time rebuild will work. But if in the CSproj file you would like add some custom action in between of Clean and Build action then i think the unit actios makes sense. From VS UI perspective i will always click rebuild and not the individual menus.

Leave a Reply

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