user3231442
user3231442

Reputation: 620

Cannot get VersionControlServer service from TFS

I have a console application, which needs to download some files from source control (TFS). But when using the code below, the VersionControlServer service is null. Due to this, I cannot download the files I need.

TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(UrlSite));
tpc.EnsureAuthenticated();
bool hasAuthenticated = tpc.HasAuthenticated; // true
var versionControl2 = tpc.GetService<VersionControlServer>(); // null 
var buildServer2 = tpc.GetService<IBuildServer>(); // successful initialization
var workItemStore2 = tpc.GetService<WorkItemStore>(); // successful initialization

Upvotes: 3

Views: 1456

Answers (1)

Shiv
Shiv

Reputation: 1404

I do something similar but instantiate the TfsTeamProjectCollection slightly differently and this works from a cmdline app in our environment:

string collection = @"http://TFSSERVER:8080/tfs/DefaultCollection";
var tfsServer = new Uri(collection);
var tpc = new TfsTeamProjectCollection(tfsServer);
var versionControl2 = tpc.GetService<VersionControlServer>();
var buildServer2 = tpc.GetService<IBuildServer>();
var workItemStore2 = tpc.GetService<WorkItemStore>();

Upvotes: 2

Related Questions