我有以下代码使用.net SDK for VSTS并使用TFS2018检索TFS中的所有项目。但我只获得最顶级的项目文件夹。如何检索某个项目的子文件夹?
var uri = new Uri("https://devserver/tfs/DefaultCollection");
using (var projectHttpClient = new ProjectHttpClient(uri, cred)) {
var projects = projectHttpClient.GetProjects().Result;
}
我也尝试过将uri更改为
var uri = new Uri("https://devserver/tfs/DefaultCollection/MyProject");
但是我收到了一个Page not found错误。
以下是TFS结构的快照。我想检索次级项目。但是我只接受二级项目。用户图标的级别。
答案 0 :(得分:1)
尝试使用以下代码获取文件夹:
using Microsoft.TeamFoundation.Client;
using System;
using Microsoft.TeamFoundation.VersionControl.Client;
namespace TestCaseProject
{
class Program
{
static void Main(string[] args)
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://tfsserver:8080/tfs/DefaultCollection"));
var versioncontrols = tfs.GetService<VersionControlServer>();
var workspace = versioncontrols.CreateWorkspace("workspaceName","workspaceOwner");
String ServerFolder = @"$/TeamProject/Folder";
String LocalFolder = @"C:\Folder";
WorkingFolder workfolder = new WorkingFolder(ServerFolder, LocalFolder);
workspace.CreateMapping(workfolder);
workspace.Get();
}
}
}