Last Tuesday I was going through all tasks that we have open related to TFS Msscci provider, tfpt bind and bindings in general. One of the gems ;) I found was automating the process to bind existing solution to source control.

The story goes as follows: user is migrating source code to tfs. He can use VSSConverter or he can just copy sources to a workspace, run “tf add” and then “tf checkin”. The problem he still has, is that when he opens migrated solution in VS, it is not recognized as source controlled. The things it’s still lacking are “bindings” – pieces of information in sln and proj files, that indicate that this solution is in fact source controlled.

If the solution was bound to VSS before, then the problem may be fixed already for him, because latest VssConverter will fix bindings for you. If not, you can run “tfpt bind” which will definitely do it.

If solution was not bound at all (e.g. you were using CVS or SVN), then the solution is not that trivial. Although we don’t have a tool that would fix this situation yet, I will provide you information that can simplify the process a lot.

The possible solutions (afaik) are as follow:

  1. The most obvious one ( and the slowest). After opening the solution, go to File->Source Control->Change Source Control. Select each project and click Bind.
  2. Right click solution and choose “Add Solution to Source Control” or run DTE command File.TfsAddSolutionToSourceControl. If the solution has not been checked in yet (you still have pending adds) than you are good and the task is done. If the files are already on the server, then you will be prompted whether you want to select different location, cancel or ignore. Click Ignore.
  3. You can attempt to manually add bindings to the solution and project files (they are all text files after all). It may be very simple for a known projects but in general is less trivial – each project can have them in different format (e.g. websites, setup projects) and projects located outside of solution root add extra complexity. Please backup before, don’t checkin without proper testing etc. Do it on your own risk!

I feel that approach #2 is the simplest and safest one. You can automate it a little by running “devenv solution.sln /command file.tfsAddSolutionToSourceControl” which will open the solution and execute the command. I feel that opening the solutions after the migration is a good idea anyway, just to do a quick sanity testing.

Good luck!