Elad Lachmi
Elad Lachmi

Reputation: 10561

tfs checkout / checkin programmatically

I am building a VS2010 addin. This addin will work only for our custom project types and create a menu item that will copy the output assembly from the current solution to another solution. Both are under TFS control.

I have the following code:

var tfs = new TeamFoundationServer(address);
var version = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
var workspace = version.GetWorkspace(System.Net.Dns.GetHostName().ToString(), version.AuthorizedUser);

workspace.PendEdit(dest);
System.IO.File.Copy(source, dest, true);

Now I want to checkin the change. The problem is that I don't know how to select only that file I checked out just now? I have other pending changes in the same project and also in other projects. Will this checkin EVERYTHING I have checked out? Can I be more selective?

Upvotes: 2

Views: 2380

Answers (1)

Betty
Betty

Reputation: 9189

PendingChange[] pendingChange = workSpace.GetPendingChanges(dest);
workSpace.CheckIn(pendingChange, comments);

Workspace.GetPendingChanges Method (String)

http://msdn.microsoft.com/en-us/library/bb139277(v=vs.100).aspx

Parameters

item: The path, local or server, to the item that is being queried.

And

Workspace.CheckIn Method

http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workspace.checkin(v=vs.100).aspx

Parameters

changes The set of pending changes to check in. If you do not specify this parameter, all changes in the workspace are checked in.

comment The comment to be associated with this check-in. May be null.

Upvotes: 2

Related Questions