Click here to Skip to main content
14,548,916 members

Understanding Clean, Build and Rebuild in Visual Studio

Rate this:
4.91 (10 votes)
Please Sign up or sign in to vote.
4.91 (10 votes)
4 Oct 2013CC (ASA 3U)
Understanding clean, build and rebuild in Visual Studio

There isn’t any .NET developer using Visual Studio as IDE hasn’t used Clean, Build and Rebuild features as part of the Solution Explorer. They come in handy when we work on large projects having multiple references, projects which get updated very often or are hardly updated with any code changes.

Recently, I have being dealing with solutions having more than 40 projects with lots of proxy service references. The source code in TFS gets checked almost every hour. Sometimes it says “BUILD SUCCEED” but on running the application, everything breaks down.

I just CLEAN Solution, then REBUILD or BUILD Solution, it starts working. This isn’t magic in Visual Studio nor is it best practice to follow but it's worth knowing that what actually Clean, Build & Rebuild in Visual Studio main functionality is.

Creating a Solution in Visual Studio with Different Projects

  • Created a blank solution “CleanBuildSolution” in Visual Studio 2012.
  • Add class library project to it “EmployeeDetails” to the above solution. It has three files, EmployeeObject.cs, EmployeeOperations.cs, EmployeeStore.xml.
  • Add WPF project “EmployeeDetails.UI”. At present, it doesn’t contain any reference to class library project created above. Note: Any project template can be used Windows Forms, ASP.NET, Console, etc.

    create solution add projects

    Figure 1: Solution having 2 projects created by following the above steps

When we check the folders in this solution, it contains only files which we created in the above steps along with project files. Then, build solution in 2 ways “Right click solution –> Build Solution” or Press F6 key.

If we see now in file explorer, few folders got created like “bin”, “Debug”, “Release”, “obj”, this is the effect of BUILD SOLUTION telling that “I have now transformed the C# code into assembly”.

Referring Another Library in a Project

In the project “EmployeeDetails.UI“, add “EmployeeDetails” class library project. Now either BUILD or REBUILD solution. Here in this step “EmployeeDetails.UI” will be added with assembly and any other files part of class library. The below screen shot shows DLL, EXE, XML files of both projects.


Figure 2: Assemblies, Files, Configs when we build or rebuild a solution

Understanding the Difference between BUILD, REBUILD, CLEAN in Visual Studio

What is a Build Solution?

Build Solution – Builds any assemblies which have changed files. If an assembly has no changes, it won’t be re-built. Also, it will not delete any intermediate files.

  • Modify some code in “EmployeeDetails” library project, then BUILD solution. In the below screen shot, refer to the time stamp of DLL, EXE is updated. It happens for both projects as library project is referred in WPF application.


    Figure 3: Assemblies, EXE gets complied after code changes on BUILD solution
  • Now modify or add some code in “EmployeeDetails.UI” WPF project. Build this project to see what happens. Only WPF project gets complied or built. Figure 4 shows that only code changes gets built, not all projects.


    Figure 4: Code changed in WPF will be complied when we BUILD it.

What is Rebuild Solution?

Rebuild solution will clean and then build the solution from scratch, ignoring anything it’s done before.

Right click on the solution name “CleanBuildSolution”. What it does is deletes all the assemblies, EXEs and referred files to compile again. The screenshot below shows this:


Figure 5: Shows time stamp on assemblies, EXE in folder indicating all were deleted & recompiled

What is Clean Solution?

Clean Solution will delete all compiled files (i.e., EXEs and DLLs) from the bin/obj directory.

Right click on solution “CleanBuildSolution” or WPF project “EmployeeDetails.UI” and click on CLEAN. This will delete all the compiled files from BIN/ OBJ directory. This is quite important especially when we are working on large of inter linked projects. There is no files in BIN/ OBJ folders to show screen shot.

This Visual Studio’s feature is one of the best among its numerous features. Let's Clean, Build and Rebuild solutions everyday!!!


The post Understanding Clean, Build and Rebuild in Visual Studio appeared first on


This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-Share Alike 3.0 Unported License


About the Author

I am Mithun Pattankar, a Software Professional on day job and blogger at nights. My interests are in Microsoft Technologies like DotNet, Visual Studio, ASP.NET, WPF, WCF, C#, HTML5


Comments and Discussions

QuestionBUT when I should use build vs rebuild vs clean+build? Pin
AlexWang201016-Jan-15 9:26
MemberAlexWang201016-Jan-15 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Technical Blog
Posted 4 Oct 2013

Tagged as


10 bookmarked