Microsoft Developer’s Guide
to
Team Foundation Version
Control
Ed Hintz and Buck Hodges
Agenda
Introduction
Dogfood and Performance Statistics
Feature overview
Scenarios
Visual Studio
Command line
SDK and Extensibility
What is VS Team Foundation?
Integrated Platform for Collaborating on Software
Development Projects.
Work Item
Tracking
Version
Control
Reporting
Build
Automation
Team
Communications
Microsoft VSTS Dogfooding
Version Control
Version Control Users:
Number of Files/Folders:
Compressed File Size:
Workspaces:
Workspace File Versions:
Changesets:
Pending Changes:
Shelvesets:
Fargo, ND
4 Users
Redmond, WA
368 Users
Source:
Research Triangle, NC
42 Users
864
1,507,247/178,953
95.2 GB
1,770
48.9 Million
32,573
57,278
2,458
Copenhagen, Denmark
6 Users
Hyderabad, India
14 Users
http://blogs.msdn.com/johnlawr/archive/2006/02/16/533362.aspx
Latest: http://tfsserver:8080/VersionControl/v1.0/administration.asmx/QueryRepositoryInformation
Source Control Feature Support
Atomic Checkin
Integrated with Visual Studio
Work Item Integration
Customizable Checkin Experience
Checkin Policies
Checkin Notes
Shelving
Delta File Storage
Large File Support (>4GB)
Source Control Feature Support
Distributed Team Support
E-mail Checkin Notification
Merge and Diff Tool Configurable (see
http://blogs.msdn.com/jmanning/articles/5
35573.aspx for common tool settings)
SDK and VS Extensibility
MSSCCI Plugin as Powertoy – (VS2003,
VB and VC6)
Visual Studio Demo
Architecture
Architecture
Team Foundation Client Tier
Version Control
Proxy
Build Machine
Report Client
Team Foundation App Tier
App Tier
Standby
Server
MDAC
Team Foundation Data Tier
TFS Concepts: Workspace
Local copy of files under SCC
Isolates developer from other changes
Maps repository paths to local paths
Mappings can be scattered around local machine
Allows for cloaked paths
Server maintains inventory
Tracks file versions and local paths
TFS Concepts: Changeset
Set of committed modifications
Add, rename, delete, etc.
Atomically applied to repository
Associated with work items at checkin
Convenient unit for change management
Checkin - Under the Hood
Visual
Studio
WorkItem 33231
Work Item
Tracking
Workspace
Checkin
3
1
Validate
Policies
Custom Policy
Static Analysis
Unit Testing
Checkin Policy
Engine
WI Association
2
Commit
Changes
V2
V3
Integration Infrastructure
Events Raised for
3rd party sync purposes
V5
V4
V5
V1
Update
Work Items
Artifact
Link
Change Set 727012
Change Set 727012
Change Set 727012
Change Set 727012
Change Set 727011
Changeset 727012
Version Control
4
Check E-mail
Notification
Getting started
Create a workspace, set mappings
For example, use /template to start with
working folder mappings.
tf workspace
/template:WorkspaceName;username WS1
/s:http://tfsserver:8080
Configure diff and merge tools
tf diff /configure
Get the files from the server
tf get
Edit a file
tf edit foo.cs
Check in
tf checkin
Command line dialogs
We provide dialogs for commands involving
complex input or data display (use /i to suppress)
Changeset
Checkin
Difference (external diff viewer)
Get (conflict resolution)
History
Resolve
Shelve
Unshelve
View (associated editor)
Workspace
Shelvesets
Shelvesets are collections of pending
changes, comments, and associated work
items
Scenarios
Backup
tf shelve /i MyWork
Temporarily move changes to work on a
different issue
tf shelve /i MyWork /move
Remote code reviews
tf unshelve CoolStuff;joe
Buddy builds or coordinate changes
tf unshelve CoolStuff;joe
Shelvesets
List shelvesets
tf shelvesets
tf shelvesets /owner:joe
Delete a shelveset
tf shelve /delete MyShelveset
List the pending changes in a shelveset
tf status /shelveset:MyWork;joe
Diff the changes in a shelveset
tf diff /shelveset:MyWork;joe
Notes
To move your workspace, change your
mappings (tf workspace) and then run get
To handle changing computer names:
tf workspaces
/updateComputerName:oldName
/s:http://tfsserver:8080
To handle changing user names:
tf workspaces
/updateUserName:oldUserName
/s:http://tfsserver:8080
Renaming files
Don’t overdo it, or your branch merges will be
more tedious (for example, renames in both
the source and target)
Performance Tweaks
Use a version control caching proxy server
in remote offices
Command line
Set the BypassProxyOnLocal registry entry
(see
http://blogs.msdn.com/buckh/archive/2005/12/
12/503015.aspx for details)
On my laptop today, ByPassProxyOnLocal saved 2
seconds (my IE settings are Automatically Detect)
Visual Studio
Change the registry setting not to
automatically get missing files (see
http://blogs.msdn.com/hippietim/archive/2006/
03/14/551320.aspx for details)
Commands
Command line reference:
http://msdn2.microsoft.com/enus/library/cc31bk2e(vs.80).aspx
Command line command and option summary:
http://blogs.msdn.com/buckh/articles/Command
LineSummary.aspx
Client API
The Team Foundation Server client object
model is a set of .NET 2.0 assemblies
There are public APIs for version control,
work item tracking, build, reporting, and
more
How It Happens:
Team Foundation Core Services
Visual
Studio
IDE
External tool
(Partner or MS)
Team Foundation Object Model
Registration
Service
Notification
Service
Linking
Service
Integration
Interface
Team
Build
Integration
Interface
Version
Control
Integration
Interface
Team
Foundation
Server
Work
Items
User
Groups
Service
Team
Foundation
Core
Services
Common
Structure
Service
Version Control Client API
The primary objects are
TeamFoundationServer – this is the root object from
which you obtain a service, such as version control
or work item tracking
VersionControlServer – this is the primary interface
to the version control server for operations and
queries that are not specific to a workspace
Workspace – this object represents a workspace
and is used to pend changes, check in changes, and
perform queries specific to a workspace
Workstation – this object represents the current
computer and manages the workspace cache, which
contains the list of local paths in each workspace
Code Sample
TeamFoundationServer tfs = new
TeamFoundationServer("http://tfsserver:8080");
// Get a reference to Version Control.
VersionControlServer versionControl =
(VersionControlServer)
tfs.GetService(typeof(VersionControlServer));
Code Sample
// Determine the server and workspace based on the local path mapping.
WorkspaceInfo wsInfo =
Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory);
// Stop if we couldn't figure out the workspace.
if (wsInfo == null)
{
Console.Error.WriteLine("Unable to determine the workspace.");
Environment.Exit(1);
}
// Get a reference to our Team Foundation Server.
TeamFoundationServer tfs = new TeamFoundationServer(wsInfo.ServerUri.AbsoluteUri);
// Get a reference to the workspace.
Workspace workspace = wsInfo.GetWorkspace(tfs);
// Update this workspace.
workspace.Get();
API Code Samples
Basic Team Foundation Version Control client API example
http://blogs.msdn.com/buckh/archive/2006/03/15/552288.aspx
Displaying the labels on a file, including label comments
http://blogs.msdn.com/buckh/archive/2005/10/25/484854.aspx
Displaying the sizes and dates of files in the server
http://blogs.msdn.com/buckh/archive/2005/10/26/485458.aspx
Sample checkin policy: make sure the comment isn't empty
http://blogs.msdn.com/jmanning/archive/2006/01/21/515858.aspx
Show all pending changes on the Team Foundation server older than a
given age
http://blogs.msdn.com/jmanning/archive/2005/12/01/499033.aspx
Scanning history for the changesets that had policy override - simple
usage of QueryHistory
http://blogs.msdn.com/jmanning/archive/2005/11/04/489193.aspx
VS Extensibility
Allows customers to extend the
functionality of TF SCC in Visual Studio via
add-ins and packages
Provides access to the following:
Source Control Explorer selection and events
Pending Changes selection and events
Solution Explorer and SCC Explorer
workspace
History selection
Changeset details dialog
Shelveset details dialog
VS Extensibility
All class names start with
Microsoft.VisualStudio.TeamFoundation.VersionControl
Use the VersionControlExt object to get to
the others:
vce =
_applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionCo
ntrol.VersionControlExt") as VersionControlExt;
VS Extensibility - VersionControlExt
Method/Property
Description
Explorer
Access the Source Control Explorer. Useful for add-ins that
need to scope an operation. The class is
VersionControlExplorerExt.
FindChangeSet
Find and display a specific changeset from your add-in
History
Access the History Toolwindow from your add-in. The class
is HistoryExt
PendingChanges
Access the collection of pending changes (as displayed in
the Pending Changes Toolwindow) from your add-in. The
class is PendingChangesExt.
SolutionWorkspace
Get the Workspace object that contains the currently
opened solution. If there is no solution opened or the
solution is not under version control this will be null.
ViewChangeSetDetails
Display detailed information about a changeset
ViewShelveSetDetails
Display detailed information about a shelveset
VS Extensibility Demo
How to Write a Team Foundation Version Control Add-in for Visual Studio
http://blogs.msdn.com/edhintz/archive/2006/02/03/524312.aspx
Tfpt.exe: Team Foundation Power Toy
Fills some of the gaps in v1
Some of the command names (getcs, uu) may
change in the future
Work item tracking commands will be available
soon
Executing queries
Updating work items in bulk
Downloading and uploading attachments
Additional documentation:
http://blogs.msdn.com/buckh/articles/tfpt_docu
mentation.aspx
Currently part of the Visual Studio 2005 SDK:
http://msdn.microsoft.com/vstudio/extend
Annotate
Downloads all versions of the specified file and shows
information about when and who last changed each line
in the file
tfpt annotate example.cs
GetCS
Gets only the changes in a particular
changeset
“tfpt getcs 123”
History
Copies the functionality of the regular history
command with the addition of /followBranches
FollowBranches option results in the output
including the history of the file’s branch ancestors
Requires a single item argument (no wildcards or
recursion)
tfpt history /followBranches mycode.cs
Online
Pends edits on writable files that do not have pending
edits
Optionally includes adds of files not in version control
and deletes of files missing from disk
Supports exclusion masks
“tfpt online . /r”
Review
Optimized for a code review rather than
checking in or shelving
Rollback
Used to roll back changes that have already been
committed
If you have existing pending changes in your
workspace, use shelve /move to move them out while
rolling back changes
“tfpt rollback /changeset:3”
Unshelve
Unshelve and merge changes with the changes
currently in the workspace
Creates a backup shelveset with your changes before
unshelving
UU
Undoes unchanged files, including adds, edits,
and deletes
By default, gets the latest files in your workspace
(runs get)
Specify a particular changeset with /changeset if you
only want to check against a particular set of changes
Designed to help with a Gauntlet workflow
“tfpt uu /changeset:123”
Questions
© Copyright 2025 Paperzz