Thursday, July 24, 2008

What does "Clean Solution" under Build Menu in Visual Studio do ?

I have been using the Visual Studio 2003 and 2008 IDE everyday at work for 9 hours for almost 7 months now and still keep running into these little stuff in the IDE that either I never thought existed or seen or even if I have seen never bothered to explore further.

So, today morning, while building my project, (I usually use Ctrl+Shift+B (Build All) rather than go to the Build Menu and use the Build Solution there) from the Build Menu, I saw the Clean Solution menu that I always knew existed but never bothered to find out what for.

So, I decided to look it up on MSDN and this is what I found.

To build, rebuild, or clean an entire solution
  1. In Solution Explorer, select or open the desired solution.

  2. On the Build menu, choose Build Solution, Rebuild Solution, or Clean Solution.

    • Choose Build or Build Solution to compile only those project files and components that have changed since the last build.

      Note:

      The Build command becomes Build Solution when a solution includes more than one project.

    • Choose Rebuild Solution to "clean" the solution first, and then build all project files and components.

    • Choose Clean Solution to delete any intermediate and output files, leaving only the project and component files, from which new instances of the intermediate and output files can then be built.



So, Clean Solution apparently cleans up ur .pdb files from the solution directory and adds them back again when you build the solution again with the new component files and the output generated by them.

Another article that explain "Clean Solution" can be found here.

But then again, my curiosity did not die there, so I continued on trying to find what exactly goes on in a "pdb" file and found some really good articles.

MSDN
says

"A program database (PDB) file holds debugging and project state information that allows incremental linking of a debug configuration of your program. A PDB file is created when you build with /debug (Visual Basic/C#). You can build Visual Basic and Visual C# applications with /debug:full or /debug:pdbonly. Building with /debug:full generates debuggable code. Building with /debug:pdbonly generates PDBs but does not generate the DebuggableAttribute that tells the JIT compiler that debug information is available. Use /debug:pdbonly if you want to generate PDBs for a release build that you do not want to be debuggable.

The Visual Studio debugger uses the path to the PDB in the EXE or DLL file to find the project.pdb file. If the debugger cannot find the PDB file at that location, or if the path is invalid, for example, if the project was moved to another computer, the debugger searches the path containing the EXE followed by the symbol paths specified in the Options dialog box. This path is generally the Debugging folder in the Symbols node. The debugger will not load a PDB that does not match the binary being debugged."


Edition

Visual

Basic

C#

C++

Web Developer

Express

Topic applies Topic applies Topic does not apply Topic applies

Standard

Topic applies

Topic applies

Topic does not apply

Topic applies

Pro and Team

Topic applies

Topic applies

Topic does not apply

Topic applies

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.



Other findings :
"The dll is the actual binary that executes. The PDB is the symbols that map memory locations in the binary to symbolic names for the debugger."

Anyways, that's it from me as far as pdb and "Clean Solution" is concerned. Next time will talk about Generics (one of my favorite features in C#).

Until next time,
Happy Debugging !!!

4 comments:

Anonymous said...

Nice & concise writeup !

Hanxlk said...

Ive been using C# for sometime and i was just wondering whats this "Clean solution" mean.. thank you for the description...

PelpS said...

Very good post. Thank you!
"Cleaned" up my mind :D

Anonymous said...

I've been using VS 2010 for a couple of years and finally realized I had no idea what "Clean Solution" meant. Thanks for putting that together.