I am attempting to write a c# application that connects to TFS and retrieves work item information. Unfortunately, it seems like all examples of using the TFS SDK are using
For TFS 2015 & 2017, objects and methods mentioned have been (or are being) deprecated.
To connect to TFS using specific credentials:
// For TFS 2015 & 2017
// Ultimately you want a VssCredentials instance so...
NetworkCredential netCred = new NetworkCredential(@"user.name", @"Password1", "DOMAIN");
WindowsCredential winCred = new WindowsCredential(netCred);
VssCredentials vssCred = new VssClientCredentials(winCred);
// Bonus - if you want to remain in control when
// credentials are wrong, set 'CredentialPromptType.DoNotPrompt'.
// This will thrown exception 'TFS30063' (without hanging!).
// Then you can handle accordingly.
vssCred.PromptType = CredentialPromptType.DoNotPrompt;
// Now you can connect to TFS passing Uri and VssCredentials instances as parameters
Uri tfsUri = new Uri(@"http://tfs:8080/tfs");
var tfsTeamProjectCollection = new TfsTeamProjectCollection(tfsUri, vssCred);
// Finally, to make sure you are authenticated...
tfsTeamProjectCollection.EnsureAuthenticated();