Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用TFS API将代码签入TFS服务器_C#_Visual Studio 2012_Tfs_Tfs Sdk - Fatal编程技术网

C# 使用TFS API将代码签入TFS服务器

C# 使用TFS API将代码签入TFS服务器,c#,visual-studio-2012,tfs,tfs-sdk,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 = W

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


上面的代码正确吗?

我将命令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.");

获取最新信息并检查是否在那里看到您的代码,有时代码已签入,但TFS未写入。我使用我的帐户检查TFS服务器,文件/文件夹在那里,但状态为“挂起的更改”,我需要通过右键单击并单击签入来手动签入。如果团队项目已在那里,成功签入文件或文件夹,否则为“挂起更改”。如果TFS服务器中不存在团队项目,我们是否有办法自动签入?VersionControl.GetWorkspace采用本地工作区路径,而不是团队项目。是的,项目必须存在,以便您签入任何与之相反的内容。为了做到这一点,您使用了什么参考?提前感谢这种方法对文件夹不起作用,当我尝试只签入文件夹而不签入其中的文件时,我得到一个例外:“没有签入的文件。”。