2

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Elad Lachmi
  • 10,406
  • 13
  • 71
  • 133
  • possible duplicate of [Programatically checkout a file in TFS 2010](http://stackoverflow.com/questions/6764883/programatically-checkout-a-file-in-tfs-2010) – Betty Nov 09 '12 at 07:27
  • possible duplicate of [Scripting TFS Command Line for Get Latest Version, Check Out and Check in, programmatically](http://stackoverflow.com/questions/3762812/scripting-tfs-command-line-for-get-latest-version-check-out-and-check-in-progr/3763449#3763449) – Ewald Hofman Nov 09 '12 at 16:06
  • 1
    @Betty - Not a duplicate of either of these. My question is not about command line, it's about C# code and my problem is not with the checkout, it's with the check in. Maybe you can read the question before commenting next time. – Elad Lachmi Nov 10 '12 at 11:20
  • The second comment wasn't from me, but you're right, i'm not sure why i recommended that post when you clearly already had the checkout working. – Betty Nov 10 '12 at 18:24

1 Answers1

2
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.

Betty
  • 9,109
  • 2
  • 34
  • 48