Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check-in code into TFS Server by using TFS API

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?

like image 425
Hoang Nguyen Avatar asked Feb 24 '26 10:02

Hoang Nguyen


1 Answers

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.");
like image 183
Hoang Nguyen Avatar answered Feb 27 '26 00:02

Hoang Nguyen