使用TFS API在TFS服务器中签入代码

时间:2013-12-10 06:24:30

标签: c# visual-studio-2012 tfs tfs-sdk

我正在编写c#代码以签入代码到TFS服务器:

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

但我得到的错误是

  

“没有签入文件”,LocalWorkingPath下的所有文件/文件夹都是“待更改”。

以上代码是否正确?

1 个答案:

答案 0 :(得分:1)

我将命令WS.GetPendingChanges()更改为WS.GetPendingChanges(tfsServerFolderPath,RecursionType.Full),它正在我这边工作。

以下是详细信息:

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