Karachi   ->   Sweden   ->   Karachi, again   ->   Dubai   ->   Bahrain   ->   Karachi, once more   ->   London and Leeds

Wednesday, January 04, 2012

How to clean C++ projects in VS 2010

If you archive/ zip your C++ project, there are good chances that it will take a lot of time to send it via email; reason being the huge temporary files that are created with VS 2010. These temporary files shouldn't be committed to your configuration management systems (CVS, SVN and similar tools). Not only adding these temporaries to your versioning system increases the storage requirements, it also adds communication overhead whenever you checkin and checkout.

VS 2010 C++ Temporary Project Files
So, how do you get rid of these huge files? The first step is to know what these files are. Below is applicable to C++ projects created with VS 2010. Similarities as well as differences exist if you are working with other languages/ versions of VS.

Your project solution folder contains the following temporary files:
  1. .suo: Contains "Solution User Options" --- user dependent information such as user tasks
  2. .sdf: Your code browsing database in SQL Server Compact Edition format; this file is recreated as soon as you load a project into Visual Studio
  3. .opensdf: Temporary file created as soon as you load a project into Visual Studio; usually deleted when you close the IDE
You might like to keep the .exe (executable) but the rest are temporary files such as
  1. .ilk: Increment Like file
  2. .pdb: Program debug database file is used by the debugger
All files are temporary and can be safely deleted; in fact, the entire folder can be deleted.

Typically your project exists in a project inside your solution folder. All files in Debug folder inside "Solution\Project\Debug" are temporary and regenerated when a build command is invoked.

The Easy Way to Delete These Files
An easy way to delete a lot of these files is to "Clean Solution" from within VS 2010. Select "Build" from the menu and choose "Clean Solution." This takes care of a lot of temporary files mentioned above, and significantly reduces your project size. This, however, deletes your .exe file as well, which you might or might not want to happen. And finally, it leaves the .sdf file, which can be significantly large, and should be deleted.

No comments:

Post a Comment