Microsoft.TeamFoundation.VersionControl.Client位置?

Microsoft.TeamFoundation.VersionControl.Client location?

我有这个 nuget 包(和非扩展包):https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/

我看到的是 Microsoft.TeamFoundation.VersionControl.Client.dll 的替代品。不幸的是,我正在尝试访问 Microsoft.TeamFoundation.VersionControl 命名空间,但它似乎不存在。我看到 Git 和 SourceControl 的条目,但是 VersionControl 抛出一个 "The type or namespace name 'VersionControl' does not exist in the namespace 'Microsoft.TeamFoundation' (are you missing an assembly reference?)" 并且 Intellisense 没有为使用关于 VersionControlServer 等的语句提出任何其他建议。

我的意图是使用带有访问令牌的 TFVC,让自动化服务器拉下一个工作区,操作一些文件,然后上传到一个新的工作区。我已经制定并编写了其余的逻辑,但 "missing" 参考只是导致问题。

我也没有真正看到任何关于它可能去了哪里的文档。有什么想法吗?

如果我没听错的话: 只需将 nuget 包下载到一个新的空项目中。您会看到名称空间就在那里。 也许您通过让自己的命名空间包含您要引用的命名空间的一部分来隐藏命名空间,例如您可能拥有:

namespace My.Microsoft.TeamFoundation.VersionControl 
{
    // ... your code ...
}

在这种情况下,您应该更改命名空间名称,或使用“global::”(https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx)。

它在 Microsoft.TeamFoundation.VersionControl.Client 命名空间中。我安装了这些 nuget 包:

Microsoft.TeamFoundationServer.Client
Microsoft.TeamFoundationServer.ExtendedClient

两个版本 14.102.0

没有Microsoft.TeamFoundation.VersionControl命名空间,也没有VersionControl class,VersionControlServer在Microsoft.TeamFoundation.VersionControl.Client命名空间中。

创建工作区和添加文件并签入的简单示例:

 NetworkCredential cred = new NetworkCredential("[account name]", "[person access token]");
             TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://[xxx].visualstudio.com"), cred);
            tpc.EnsureAuthenticated();
            VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
Workspace workspace = versionControl.CreateWorkspace("TestWorkspace", versionControl.AuthorizedUser);
try
            {
                String localDir = @"c:\temp\BasicSccExample";
                //Console.WriteLine("\r\n--- Create a mapping: {0} -> {1}", args[1], localDir); 
                workspace.Map("$/Agile2015/APIFolder", localDir);


                workspace.Get();

                Console.WriteLine("\r\n--- Create a file.");
                topDir = Path.Combine(workspace.Folders[0].LocalItem, "sub");
                Directory.CreateDirectory(topDir);
                String fileName = Path.Combine(topDir, "basic.txt");
                using (StreamWriter sw = new StreamWriter(fileName))
                {
                    sw.WriteLine("revision 1 of basic.txt");
                }

                Console.WriteLine("\r\n--- Now add everything.\r\n");
                workspace.PendAdd(topDir, true);

                Console.WriteLine("\r\n--- Show our pending changes.\r\n");
                PendingChange[] pendingChanges = workspace.GetPendingChanges();
                Console.WriteLine("  Your current pending changes:");
                foreach (PendingChange pendingChange in pendingChanges)
                {
                    Console.WriteLine("    path: " + pendingChange.LocalItem +
                                      ", change: " + PendingChange.GetLocalizedStringForChangeType(pendingChange.ChangeType));
                }

                Console.WriteLine("\r\n--- Checkin the items we added.\r\n");
                int changesetNumber = workspace.CheckIn(pendingChanges, "Sample changes");
                }

根据 Fredy Treboux 的建议测试了一个新项目,它在那里工作。

那时我完全卸载了所有与 TFS 和 VS 服务相关的包,并确保为它们删除了所有文件,然后重新安装。似乎已修复它,所有引用现在都没有错误。