我目前有一个使用TFS客户端API的项目。这个项目在C#里。该项目引用了以下构造:
下面是当前代码的示例:
using (TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(collectionUri)))
{
VersionControlServer vcServer = tpc.GetService<VersionControlServer>();
ItemSet itemSet = vcServer.GetItems("$/", RecursionType.OneLevel);
foreach (Item item in itemSet.Items)
{
//do stuff with the item
}
}
现在,我在VSTS (配置为使用Git)中有我想要针对的项目。根据我到目前为止所看到的,如果您使用Git源,上述构造在VSTS客户端API中并不存在。
源为Git的VSTS客户端API中的等效结构是什么?
下面是我的VSTS示例代码:
VssConnection connection = new VssConnection(new Uri(vstsOrTfsCollectionUrl), new VssClientCredentials());
//The ProjectHttpClient
ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>();
BuildHttpClient buildServer = connection.GetClient<BuildHttpClient>();
//Get Basic Project - Shallow Reference
IEnumerable<TeamProjectReference> projects =
projectClient.GetProjects().Result;
//Create GIT since some projects use Git
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
..projectName.. and other code here..
TeamProject theProject = projectClient.GetProject(projectName).Result;
List<GitRepository> gitRepositoryList =
gitClient.GetRepositoriesAsync(theProject.Name).Result;
发布于 2018-08-16 01:41:24
您提到的第一个代码是版本控制系统(TFVC),而不是Git。TFVC和Git是不同的版本控制系统,API的结构也不同。所以你不会为Git找到相同的构造。如果希望获取Git存储库中的项,请在GetItemsAsync()
中使用GitHttpClient方法。
顺便说一下,您提到的TFS客户端API是遗留的SOAP,而VSTS客户端API是新的Rest。它们都适用于TFS和VSTS。
https://stackoverflow.com/questions/51864875
复制相似问题