Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eliminate temporary files in visual studio solution folder

I am cleaning up a bunch of visual studio projects / solutions from different sources, and there are an incredible amount of temporary files and temporary folders stored in each solution.

I am wondering what file types are safe to delete so that I can write a script to take care of the heavy lifting so there is less junk to push around when I am trying to get the whole folder structure organized and linked up to the proper shared file locations.

As far as I can see the following files and folders are temporary and can be safely deleted:

Files

  • *.sdf
  • *.sln.docstates
  • *.suo
  • *.upgradelogxml
  • *.user
  • *.vcxproj.filters
  • *.sln.old
  • *.suo.old
  • UpgradeLog.XML
  • *.wixproj.vspscc
  • *.csproj.vspscc
  • *.SCC
  • *.ncb
  • *.opt
  • *.plg
  • *.aps
  • *.clw

Folders

  • _UpgradeReport_Files (folder)
  • ipch (folder)
  • bin, obj, debug, release and other build output folders though there could be files copied into here during build...
  • Backup, Backup1, etc...

I am not even sure what some of these file types really are, I just know they are re-generated when you open the solution - and I know there are many more file types that I have missed from older and newer versions of Visual Studio.

Are there any file types that should be preserved in the list above? If so, for what reason, and are there further file types that can be cleaned out without any serious side effects?

The overall idea is to minimize the size and complexity of the solution when it is to be migrated, moved or reorganized or otherwise shuffled around enough for this "solution fat" to be a serious performance and management problem.

Typically I see this problem if I need to check something into a new source control system, zip and send sample code by email or put third party or peer code into an existing hierarchy of shared folders and files.

like image 644
Stein Åsmul Avatar asked Sep 14 '12 16:09

Stein Åsmul


2 Answers

I disagree with your list of "temporary" files - certainly very few of them are temporary in nature (otherwise they'd be in the %TEMP% directory). Granted, most of them are not necessary for your project to build successfully, but they are still important.

  • sdf - SQL Server Compact database. Used by VS2012 to store VC intellisense data. Without this file you will not get intellisense and code-completion until it rebuilds.
  • sln.docstates - Stores temporary state information about files in your solution.
  • suo - Contains information about your per-solution IDE customization settings, such as window layout and toolbox loadout. It's generally safe to delete this but your solution might take longer to load in future and you'll lose any UI customizations.
  • upgradelog.xml - Yeah, the upgrade-log files are a bit of a mess. This can be deleted.
  • user - I'm sure this is an old file from VC6 days...
  • vcxproj.filters - Keep this, it's a per-computer/per-project filesystem organisation list thingie
  • sln.old - "old" files are not VS files. This looks like a backup file made by a user or tool.
  • suo.old -
  • UpgradeLog.XML - this can be deleted if you're not using the UpgradeLog tool
  • wixproj.vspscc - never delete this file if you're using source control. It's part of VS's source control integration. It's hell trying to re-integrate unchecked changes back into source-control after deleting binding files. Only delete this if you're not using source control.
  • csproj.vspscc - same as above.
  • SCC - Used for source control. Never delete this if you're using source control.
  • ncb - Intellisense cache used in VC6 through 2010. If you delete this you'll lose VC intellisense until the IDE has rebuilt it, which can take aaaggess on large projects.

I've no idea what this or the other files are: .opt, .plg, .aps, .clw

Of course, the trick is to properly arrange your files in your solution in the first place. Project source files should be kept separate from project metadata (i.e. the files I just listed above), ideally in separate folders in their own heirarchy (that way you can have multiple VC project files for the same source code, allowing contributors to use VC2005, 2008, and 2010 at the same time).

like image 112
Dai Avatar answered Sep 23 '22 03:09

Dai


Have a look at the folders and extensions listed in the answers to this Visual Studio .gitignore question for an idea of the files that are commonly considered non-essential.

However, it is generally speaking not a good idea to delete stuff if you don't know what it is. For example, .sdf files may be SQL Server CE databases, which might be important in some projects. So make sure you make a backup somewhere before running any solution cleaner scripts.

like image 27
Mark Heath Avatar answered Sep 26 '22 03:09

Mark Heath