Home > Uncategorized > Remove Source Control Bindings – Visual Studio 2008

Remove Source Control Bindings – Visual Studio 2008

Ever find yourself giving code to someone else? Maybe its an official handover of the source, or perhaps an example to post on your blog. Well, if you keep your solution in Team Foundation Server and it is bound to source control, then the solution will contain information about its TFS bindings. If you’ve ever attempted to open a solution with such bindings, but are unable to contact TFS, you get a series of popups indicating that TFS couldn’t be found, would you like to work offline, etc. This is certainly not something you want other people to have to put up with when you give them your solutions, its just bad form!

It is quite easy to remove these bindings in Visual Studio. You can unbind via ‘File -> Source Control -> Change Source Control’ and this works just fine. Your solution and project files will have the relevant source control sections removed, and the extra files (.vssscc and .vspscc) will be deleted.

But what if you want to automate this process?

Unfortunately there are not a lot of options around. Deleting the files is pretty easy; create an item group for the two extensions above, and call the delete task on them. But what about modifying solution and project files? This has prompted people to come up with their own solutions, one such as from John Robbins who created an MSBuild task for removing these bindings. Unfortunately John’s task did not work for me and I presume this is because he targets Visual Studio 2005, not 2008 (the article was written in 2006). This gave me the fuel to come up with my own solution instead.

Download Snagy.Tasks.dll

The above download will give you the DLL and an example MSBuild file to use. There are essentially 2 tasks that do two separate things.

RemoveTFSBindings

This task removes bindings from SLN and CSPROJ files. I have no immediate plans to add support for VBPROJ or DBPROJ but if you really want these included, I am happy to do so. Just email me.

This task is called like this:

<RemoveTFSBindings SourceFile="Src.sln" TargetFile="New.sln" />

Yes, it only processes one file at a time, however it is quite easy to call it with an item group as follows:

<ItemGroup><ProjectFiles Include="$(path)\**\*.sln;$(path)\**\*.csproj" /> </ItemGroup>
<Target …>
  <RemoveTFSBindings SourceFile="%(ProjectFiles.Identity)" ReplaceTarget="true" />
</Target>

The above example will replace each file with a version of the file without source bindings.

RemoveSCCBindingFiles

This task removes all dedicated source control files in a given folder, with the option of repeating the process recursively. It is called like this:

<RemoveSCCBindingFiles Folder="$(path)" Recursive="true" />

It targets and deletes all .vssscc and .vspscc files.

Usage

Not sure how to use a custom task? All you need to do is import each task with the ‘UsingTask’ task, like this:

<UsingTask TaskName="Snagy.Tasks.RemoveTFSBindings" AssemblyFile=".\Snagy.Tasks.dll" />
<UsingTask TaskName="Snagy.Tasks.RemoveSCCBindingFiles" AssemblyFile=".\Snagy.Tasks.dll" />

Disclaimer

I’ve tested the tasks on a variety of projects created by different people and it seems to work fine. That being said, I’m standing by the "It works on my machine" motto. I can’t guarantee it will work for you. Please note that my tests have been specifically around TFS and doubt that this will work for any other source control binding.

Also, I included an EXE version as well just in case you wanted a different avenue of usage. I only did this though because Paul Stovell begged and pleaded for it. Its included in the download link above.

Good luck!

Categories: Uncategorized
  1. 小锋
    December 16, 2009 at 8:15 pm

    Really an easy way to remove it. Many thanks!

  1. No trackbacks yet.

Leave a comment