views:

190

answers:

2

I'm using the TFS 2010 SDK to programmatically check in edits to files into TFS 2010. The documentation on the TFS 2010 SDK is sparse at best. When I call the method workspace.pendedit() passing in an array of files I want to mark as having a pending edit, nothing is actually checked out. So when I call workspace.checkin() passing in workspace.getpendingchanges and some comments I get an exception that there must be at least one thing that has a pending change (which should be what I passed into pendedit). Any thoughts on why the app isn't marking the files as having a pending edit in the workspace?

A: 

Make sure you're doing everything in the right order so TFS knows that the file has changed. You have to:

  1. Get the file from the workspace first.
  2. Pend the edit
  3. Make the changes to the file
  4. Check in the workspace.

Example:

    GetStatus status = workspace.Get(new GetRequest(migrationPath, RecursionType.None, 
                                             VersionSpec.Latest),GetOptions.Overwrite);
    workspace.PendEdit(migrationPath);

    checkInAuthor = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Robaticus
A: 

It turned out that even though I had added the files and checked in the files, it seemed that the workspace didn't recognize that the files were there, and as a result I had to do a Get() prior to the PendEdit()

MasterMax1313