||Carlos J. Quintero (Microsoft MVP)
||Microsoft Visual Studio .NET 2002
||Microsoft Visual Studio .NET 2003
||Microsoft Visual Studio 2005
||Microsoft Visual Studio 2008
||Microsoft Visual Studio 2010
||Microsoft Visual Studio 2012
This article provides information about how interact with a source code
control (SCC) provider from a Visual Studio add-in.
All versions of Visual Studio provide built-in integration with source code
control (SCC) providers, which can be configured in the "Tools", "Options"
window, "Source Control" section. There are some differences between Visual
Studio .NET 2002/2003 and Visual Studio 2005:
- Visual Studio .NET 2002/2003 can use only SCC providers based on the
Microsoft Source Code Control Interface (MSSCCI) API. Visual Studio 2005 can
use not only MSSCCI-based providers but also source control providers can
use the Visual Studio 2005 SDK to provide a package that replaces the
package used for MSSCCI-based providers, using new menus, dialogs or
windows. For example, when using a MSSCCI-based provider Visual Studio 2005
offers the "View", "Pending Checkins" window, while when using Team
Foundation Server that menu is hidden and a new, different, "View", "Other
Windows", "Pending Changes" window is shown. See the
Overview of Source Control Integration section of the Visual Studio 2005
- Visual Studio .NET 2002/2003 can use only the default SCC provider
(specified in the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\SourceCodeControlProvider)
of the several ones that you may have installed on your machine. Visual
Studio 2005 allows you to select the source control provider through a
combobox in the "Tools", "Options" window, "Source Control" section.
For example, Visual Source Safe 6.0 is a MSSCCI-based source control
provider. Team Foundation Server (TFS) is not MSSCCI-based, Visual Studio 2005
provides a new package that replaces the MSSCCI-based package. To use Team
Foundation Server from an IDE that only supports MSSCCI providers you need to
Visual Studio 2005 Team Foundation Server MSSCCI Provider. You can learn
more about source control packages for Visual Studio 2005 in the
Source Control section of the Visual Studio 2005 SDK documentation.
There are several approaches that your add-in can use to interact (invoke
operations or receive events) with source code control:
- The extensibility model provides the EnvDTE.SourceControl class (you can
retrieve an instance through the EnvDTE.DTE.SourceControl property). This
class provides methods to check out files, to exclude files from source
control and to know if a file is under source control or checked out.
- If you are using Visual Studio 2005 and higher, you can use the new
EnvDTE80.SourceControl2 class (you can retrieve an instance casting the
returned value of EnvDTE.DTE.SourceControl property to SourceControl2). This
class provides additional functionality not available in the
- You can execute source control commands (such as "File.AddSolutiontoSourceControl",
"File.CheckIn", "File.CheckInSilent", etc.) using the
EnvDTE.DTE.ExecuteCommand(commandName) method. You can learn the command
names using the "Tools", "Customize..." window, "Keyboard..." button.
- You can get BeforeExecute/AfterExecute command events for those
commands. See the article HOWTO: Capturing
commands events from Visual Studio .NET add-ins.
- You can get the
IVsSccXXX interfaces from the IDE and use them from your add-in. See
How to: Get a Service from the DTE object.
- If you are using specifically Team Foundation Server, you can use the
Microsoft.TeamFoundation.VersionControl.Client namespace (which is not
specific to Visual Studio 2005). See the
Version Control Extensibility section of the Team Foundation Server SDK.
If you want to use the objects that the Team Foundation Server package
provides for Visual Studio 2005 integration (such as the Source Control
Explorer, etc.) you can use the private
Microsoft.VisualStudio.TeamFoundation.* assemblies. See
How to Write a Team Foundation Version Control Add-in for Visual Studio.
- If you are using specifically Visual Source Safe, you can use
Visual SourceSafe Automation and
Visual SourceSafe Automation Reference.
Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this