Share via


VSPackage Structure (Source Control VSPackage)

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The Source Control Package SDK provides guidelines for creating a VSPackage that allow a source control implementer to integrate his or her source control functionality with the Visual Studio environment. A VSPackage is a COM component that is typically loaded on demand by the Visual Studio integrated development environment (IDE) based on the services that are advertised by the package in its registry entries. Every VSPackage must implement IVsPackage. A VSPackage typically consumes services offered by the Visual Studio IDE and proffers some services of its own.

A VSPackage declares its menu items and establishes a default item state via the .vsct file. The Visual Studio IDE displays the menu items in this state until the VSPackage is loaded. Subsequently, the VSPackage's implementation of the QueryStatus method is called to enable or disable menu items.

Source Control Package Characteristics

A source control VSPackage is deeply integrated into Visual Studio. The VSPackage semantics include:

  • Interface to be implemented by virtue of being a VSPackage (the IVsPackage interface)

  • UI Command implementation (.vsct file and implementation of the IOleCommandTarget interface)

  • Registration of the VSPackage with Visual Studio.

The source control VSPackage must communicate with these other Visual Studio entities:

  • Projects

  • Editors

  • Solutions

  • Windows

  • The running document table

Visual Studio Environment Services That May Be Consumed

SVsShell

SVsUIShell

SVsSolution

SVsRegisterScciProvider Service

SVsQueryEditQuerySave

SVsTrackProjectDocuments

SVsSccManager

VSIP Interfaces Implemented and Called

A source control package is a VSPackage, and therefore it can interact directly with other VSPackages that are registered with Visual Studio. In order to provide the full breadth of source control functionality, a source control VSPackage can deal with interfaces provided by projects or the shell.

Every project in Visual Studio must implement IVsProject3 to be recognized as a project within the Visual Studio IDE. However, this interface is not specialized enough for source control. Projects that are expected to be under source control implement IVsSccProject2. This interface is used by the source control VSPackage to query a project for its contents and to provide it glyphs and binding information (the information needed to establish a connection between the server location and the disk location of a project that is under source control).

The source control VSPackage implements IVsSccManager2, which in turn allows projects to register themselves for source control and retrieve their status glyphs.

For a complete list of interfaces that a source control VSPackage must consider, see Related Services and Interfaces.

See also