3

I'm writing c# code to check-in code to TFS server:

Workspace WS = VersionControl.GetWorkspace(TeamProject);
WS.Map(TFSMapServerPath,LocalWorkingPath);

int NumberOfChange = WS.PendAdd(string.Format(@"{0}\Main\DotNet\",LocalWorkingPath),true);

PendingChange[] pendingChanges = WS.GetPendingChanges();        
WS.CheckIn(pendingChanges,"Auto Check-in");

But i got the error is

"No files checked in", all files/folders under LocalWorkingPath are "Pending Change".

Are the above codes correct?

Raptor
  • 53,206
  • 45
  • 230
  • 366
Hoang Nguyen
  • 1,348
  • 1
  • 10
  • 17
  • get latest and check if you see your code there, sometimes the code checked in but the TFS write that it not. – Hadash Dec 10 '13 at 06:31
  • I used my account to check TFS Server, files/ folder are there but the status is "pending changes" and i need to manually check-in by right click on that and click on check-in. – Hoang Nguyen Dec 10 '13 at 07:07
  • If Team project already there, files or folders checked-in sucessfully otherwise it is "pending Change". Do we have any ways to check-in automatically in case of Team Project doesn't exist in TFS Server? – Hoang Nguyen Dec 10 '13 at 07:11
  • 1
    VersionControl.GetWorkspace takes in the local workspace path and not team project. And yes the project has to exist for you checkin anything against it. – allen Dec 10 '13 at 07:26

1 Answers1

2

I changed the command WS.GetPendingChanges() to WS.GetPendingChanges(tfsServerFolderPath,RecursionType.Full) and it is working at my side.

Here is detail:

        //Get the current workspace
        WS = versionControl.GetWorkspace(workspaceName, versionControl.AuthorizedUser);     

        //Mapping TFS Server and code generated
        WS.Map(tfsServerFolderPath,localWorkingPath);

        //Add all files just created to pending change
        int NumberOfChange = WS.PendAdd(localWorkingPath,true);
        //Get the list of pending changes
        PendingChange[] pendings = WS.GetPendingChanges(tfsServerFolderPath,RecursionType.Full);

        //Auto check in code to Server
        WS.CheckIn(pendings,"CodeSmith Generator - Auto check-in code.");
Hoang Nguyen
  • 1,348
  • 1
  • 10
  • 17