Click here to Skip to main content
15,897,704 members
Articles / All Topics

Build, Rebuild & Clean Solution: A Fact

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
22 Apr 2016CPOL3 min read 6K   1  
Build, rebuild and clear solution: A fact

Why This?

Just out of curiosity, I thought of why Build, Rebuild & Clean Solution in Visual Studio IDE. Earlier, I thought I could use any one of them, i.e., Build & Rebuild, they do the same! but I still thought of going through few resources and getting the differences and I was staggered to find that I was wrong. ??

This is a very simple and basic fact, which every developer using VS should be aware of. I wanted to be aware of this before someone questions me the same. I will be discussing their work and describing each as an Agent.

Discuss Facts!

7

Let's first discuss about Build Solution.

Build Solution

:-

‘Ctrl + Shift + B’

The short cut above to build a solution. Now what does this Build agent do in the background!

The Build Agent

1

This agent of the VS IDE does an incremental build. If you build your solution once, with some files changed, then it will build only those files which you have changed, without touching the files that are not even touched by you. ??

Moreover, if you are building the Solution once and then again doing a build, it will not again build the solution actually, as the agent finds no files that are changed!

We see the build result on the output window in the IDE.

Let's see a pictorial difference.

4

As you see in the above image, the DLL of the project gets re-generated, as a file was modified under that project. Since my solution has a single project, it creates the DLL of that only.

5

In the above image as we hit the Build, the Build is succeeded but shows ‘0 succeeded’, i.e., there were no files modified, for which it did not create any DLL.

8

Re-Build Solution

2

This agent is the master of all. This is the combination of Clean & Build.

9

This does not check or bother if there are any changed/modified files, it will always do a clean and build the solution or the specific project. This will recompile and regenerate the DLLs inside the bin folder.

Clean Solution

3

The clean Madam, cleans and removes all the DLLs created inside the bin folder. The procedure she follows is simple, just remove the DLLs related to the project or related to the entire solution from the bin folder.

Before Clean, the bin folder has all the DLLs:

10

After the clean when the clean succeeds, all the DLLs are removed by the clean agent.

11

When To Use What

To be honest, we can use any of them, I prefer a Clean first and then a Build. What do you do?

When we:

  • Rebuild a Solution with 2-3 projects, then the Re-build agent cleans the project 1 and then builds the project 1. Similarly, cleans project 2 and builds project 2 and so on.
  • When we clean and then build a solution, then the Clean agent first removes all the DLLs for each project and then the build agent generates the project DLLs at once.

Thus, I have shared a simple tip and know how fact which might be handy and mandate as we are Visual Studio developers!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --