Tony Wall’s Blog

Remember quality? A bit more time upfront saves a ton of trouble later ;-)

Scorching Source Code

Microsoft Visual Studio

After much experience of the issues related to switching between different PCs with Visual Studio source bound solutions, I was pleased to find the “scorch” feature of Visual Studio Team Foundation Power Tools.

Previously Visual Studio just didn’t clean itself up properly. This would leave duplicate and extra files when deletes or renames occurred on other PCs or by other users. The next developer could then mistakenly open or edit the wrong file, potentially losing changes without knowing it. Knowledge of such issues discourages developers from making proactive refactoring, e.g. for readability, consistency and reduced maintenance costs.

Another major issue was the failure of Visual Studio to update local files even when the current copy was out of date or missing. The only solution to this was to “Get Specific Version” with the option to get files even when they should exist. An assumption is apparently programmed into Visual Studio to only use the last known source control status, not bothering to check the actual files.

The SCORCH command is a combination of the TREECLEAN command which deletes extra files, plus verification that all local files are the correct version. Deleting extra files will also eliminate any compiled object, binary, test results and other outputs. This significantly reduces the size of your local source copy in case you want to take a backup or have limited disk space. Removing intermediary files can help avoid issues when shared components are updated but a local cache of older versions still exist.

With all these benefits, I’d strongly recommend that “scorching your source” (as I like to call it) should be a best practice performed regularly by developers whether in a team or stand-alone switching between different PCs. It is especially important to do before going away to work offline, checking-in offline changes, coming back from holiday or any other situation where major changes to the dependencies or structure of the source may have occurred.

Here’s how you do it:

  1. Make sure you installed the Team Foundation Power Tools. Best place to do this is via the “Tools” – “Extension Manager” (NuGet) or directly here:
  2. Open a command prompt.
  3. Enter the command “tfpt scorch <path> /recursive /diff” where “<path>” is the root directory of your source collection.
  4. Wait for it to scan your source tree, review changes (but no extra effort is usually required), then confirm to clean-up and update your local files.
  5. Repeat the command for any other collections/source root paths you have from your Team Foundation Server, e.g. sometimes one for each customer or business subsidiary.
  6. Run “tfpt scorch /?” for further options. It can be automated, although you shouldn’t do that unless you also go online/shelve/check-in any unsaved changes first.
Tagged , , ,

2 thoughts on “Scorching Source Code

  • This is exactly what I was looking for. It did however take me a while to figure out that the /diff option must be specified in order for scorch to clean out test results from MSTest.

    1. Actually, scratch that – the /diff option is not necessary for scorch to clean out test results. It may however catch some files it would have missed otherwise. This is because the /diff option tells scorch to use MD5 hashes to compare items with source control, which obviously makes it take MUCH longer.

      Here’s another tip: to tell scorch to leave your project settings alone, use the /exclude:*.user option.

Leave a Reply

Your email address will not be published. Required fields are marked *