Basic Source Control Operations Sample

The Basic Source Control Example includes one project. It shows how to build console applications to work with Source Control Extensibility without invoking the Visual Studio IDE.

To build the project

  1. In the Sample Browser, right-click C# Example.BasicSccOperations, and select Open in VS.

  2. For any missing references, manually re-add a reference to these DLLs in the Common7\IDE\PrivateAssemblies folder of your Visual Studio install path.

    • Microsoft.TeamFoundation.Client

    • Microsoft.TeamFoundation.VersionControl.Client

    • Microsoft.TeamFoundation.VersionControl.Common

  3. Open VersionControlExample.cs.

  4. Create a Team Project named "proj" or replace "$/proj" in VersionControlExample.cs with the name of your Team Project.

  5. If you do not want to use the default of "d:\temp\BasicSccExample," edit line 50 to reference a local hard disk drive.

  6. Press F6 to build the sample.

  7. After building, type "BasicSccExample.exe" in the console to print its usage.

Requirements

  • Team Foundation Server installation and the name of the server.

  • A computer that has Visual Studio installed.

  • A computer that has Team Explorer installed.

Demonstrates

Shows how to write console-based access to the Version Control Server of Visual Studio 2005 Team System.

Source Files

VersionControl.cs

Main()

  • Confirms appropriate number of parameters.

  • Connects to the TeamFoundationServer.

  • Connects to the VersionControlServer.

  • Subscribes to Source Control events:

    • BeforeCheckinPendingChange

    • NonFatalError

    • Getting

    • NewPendingChange

  • Creates a Workspace and a WorkingFolder.

    Note: WorkingFolder should be edited for your computer's local configuration

  • Creates a mapping to the WorkingFolder.

  • Gets files from the repository.

  • Creates a new file that is named "basic.cs" which contains the line "revision 1 of basic.cs."

  • Queues the changes (the new basic.cs file) to be added to the repository.

  • Shows the pending changes.

  • Checks in the pending changes.

  • Checks out the basic.cs file.

    This changes the file contents to "revision 2 of basic.cs"

  • Gets the pending changes.

  • Checks in the pending changes.

  • Queues the deletion of the new file.

  • Deletes the new file and workspace.

OnNonFatalError()

  • Shows the exception or failure.

OnGetting()

  • Shows the item to be received and its status.

OnBeforeCheckInPendingChange

  • Shows the item being checked in.

OnNewPendingChange

  • Shows the type of pending change, and the item being changed.

See Also

Other Resources

Source Control Extensibility