【问题标题】:Check-in code into TFS Server by using TFS API使用 TFS API 将代码签入到 TFS 服务器
【发布时间】:2013-12-27 13:31:57
【问题描述】:

我正在编写 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 下的所有文件/文件夹都是“待更改”。

以上代码正确吗?

【问题讨论】:

  • 获取最新信息并检查您是否在那里看到您的代码,有时代码已签入,但 TFS 写的却没有。
  • 我使用我的帐户检查 TFS 服务器,文件/文件夹在那里,但状态为“待更改”,我需要通过右键单击手动签入并单击签入。
  • 如果团队项目已经存在,文件或文件夹已成功签入,否则为“待更改”。如果 TFS Server 中不存在 Team Project,我们有什么方法可以自动签入?
  • VersionControl.GetWorkspace 接受本地工作空间路径,而不是团队项目。是的,该项目必须存在,以便您检查任何针对它的内容。

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


【解决方案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.");

【讨论】:

  • 你使用什么参考来做这个?提前致谢
  • 这种方法不适用于文件夹,当我尝试只签入没有文件的文件夹时,我得到一个异常:“没有文件签入。”。
猜你喜欢
  • 2012-04-14
  • 2019-01-26
  • 2011-08-29
  • 1970-01-01
  • 2015-12-29
  • 2011-02-18
  • 1970-01-01
  • 2018-05-04
  • 2014-06-12
相关资源
最近更新 更多