Check-in code into TFS Server by using TFS API

不羁岁月 提交于 2019-12-19 09:43:31

问题


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?


回答1:


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.");


来源:https://stackoverflow.com/questions/20487590/check-in-code-into-tfs-server-by-using-tfs-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!