Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 267
user3231442 Avatar asked May 22 '26 17:05

user3231442


1 Answers

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>();
like image 181
Shiv Avatar answered May 24 '26 07:05

Shiv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!