【发布时间】:2016-10-11 14:25:34
【问题描述】:
我一直在尝试访问 TFS 帐户(以编程方式使用 TFS SDK)以获取项目名称、工作项名称和每个工作项的开发时间等信息。
我无法获取项目或工作项信息,但我能够使用 TfsTeamProjectCollection 类进行身份验证和访问 TFS。
但是,使用 TfsConfigurationServer 类,我永远无法对服务器进行身份验证。很遗憾,因为我在网上看到的大多数示例都使用了这个 TfsConfigurationServer 类。
允许我访问 TFS 的代码:
// Connect to Team Foundation Server.
NetworkCredential netCred = new NetworkCredential("myEmail@email.com", "myPassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://tfs.gfi.pt:4430/tfs/gfi/"),tfsCred);
tpc.Authenticate(); // This one works, and when I enter tpc I can see I am correctly signed-in in TFS (I can for instance check my full name)
ITeamProjectCollectionService projCollect = tpc.GetService<ITeamProjectCollectionService>(); //returns null :(
我有两个问题:
- TfsConfigurationServer 和 TfsTeamProjectCollection 有什么区别?我知道第一个引导我进入服务器级,第二个引导我进入集合级,但是,服务器级和集合级是什么?
- 当我完全能够登录时,为什么我无法获取 projectCollection(当我确定我在 TFS 上有 2 个项目时,为什么最后一行返回 null)?
【问题讨论】:
-
您可能会觉得这很有帮助:stackoverflow.com/questions/39829535/…