July 28, 2009

Visual Studio and Surround SCM

Surround SCM
Recently I wrote a post on the .MySCMServerInfo file, and I mentioned that one of its uses is the IDE integration. In this post, I am going to break this down a little further, and explain the Visual Studio integration with Surround SCM in more detail.  For more information, read the Surround SCM-Visual Studio integration instructions or watch a quick video of the integration in action. One way to look at this integration is that there are two main pieces:
  • The piece that tells Visual Studio that Surround SCM is the selected source code control provider.
  • The piece that Surround SCM uses to know which branch and repository to bind to.
We already looked at the second piece in my previous post. For this post, I will focus on the first piece of the integration. How does Visual Studio know that Surround SCM is in control?When you bind a solution and/or project with any source control tool, references are added to the solution and project file. Every time you open a solution and/or project in Visual Studio, it checks for this reference.Here is an example of what your solution may look like (I opened the .sln file in Surround SCM using the built-in viewer): [caption id="attachment_739" align="aligncenter" width="553" caption="Solution under source control"]Example Visual Studio solution file with source control bindings[/caption] A similar entry is also added to the project file. Following is an example of a C# project file under source control (also viewed in Surround SCM through the built-in viewer). [caption id="attachment_741" align="aligncenter" width="536" caption="Project under source control"]Example Visual Studio project file with source control bindings[/caption] The main point is that information is embedded in the project and solution regarding the source control provider. Because of this, keep the following in mind:
  • The source control provider is set at the solution/project level. Some users have told me that they have selected the source control provider of their choice, but when they open a solution/project, the source control provider is changed. This is because the solution/project that is being opened has a reference to a different source control provider.
  • Uninstalling a source control provider will not automatically unbind your solution/projects.
  • If you change the provider make sure that the solution and/or project files are checked in. Remember that the references to the provider are part of the file content and must be checked in for those changes to be available to other users or next time you check out or get the solution/project.
How do I remove the binding? Using the Visual Studio bind/unbind mechanism should remove the binding information. Remember to save and check in the solution/project after this. Sometimes you may find that Visual Studio does not remove the binding information. Not sure if this is because the solution is set to read-only or there is a permission issue. While I cannot officially endorse this method, you could manually edit the solution and project files and remove the reference to the source control provider. You may want to compare it to a solution/project file that is not under source control so you can determine what can be deleted. How can I change from one provider to another? This question became a popular one when Surround SCM introduced its "native" plug-in, the "Surround SCM Integration Provider". The best way I have found to switch a solution/project using the "generic" plug-in (Surround SCM) to the "native" interface ("Surround SCM Integration Provider") is by following these steps:
  1. Open the solution/project.
  2. Select Tools > Options.
  3. Under Source Control, set the Current source control plug-in: to 'none'.
  4. Save the solution/project.
  5. Close the solution/project.
  6. Re-open the solution/project. You should not get any message about source control. Also, in the solution explorer, there shouldn't be any source control icons.
  7. If there aren't any traces left of the old source control provider, then you can go back to Tools > Options and under Source Control, select the desired source control provider.
  8. Save the solution/project and bind/rebind to source control and check it in.
NOTE: You don't have to close the solution/project after setting the source code control provider to 'none'. However, I find it helps me verify that the source control bindings are in fact removed when I open the solution/project back up. Do not try to associate a solution/project with a source control provider until all associations with the prior source control tool have been removed.