开发者

TfsConfigurationServer.GetService<VersionControlServer>() always returns null

开发者 https://www.devze.com 2023-02-13 05:58 出处:网络
I\'m trying to connect to TFS 2010 using TFS SDK, but can\'t get VersionControlServer service. var servers = RegisteredTfsConnections.GetConfigurationServers(); // ok

I'm trying to connect to TFS 2010 using TFS SDK, but can't get VersionControlServer service.

var servers = RegisteredTfsConnections.GetConfigurationServers(); // ok

then

var tfs = new TfsConfigurationServer(servers.First().Uri, CredentialCache.DefaultNetworkCredentials);
// or
var tfs = new TfsConfigurationServer(servers.First());

both always returns null:

开发者_运维百科
var vc = (VersionControlServer)tfs.GetService<VersionControlServer>(); // null!

What should I do?


You don't want the configuration server, you want the project collection. The version control service is scoped to a team project collection. For example:

var projectCollection =
    TfsTeamProjectCollectionFactory.GetTeamProjectCollection(registeredProjectCollection);

var versionControl = projectCollection.GetService<VersionControlServer>();

See also: Connect to a Project Collection

0

精彩评论

暂无评论...
验证码 换一张
取 消