Reputation: 137
I'm trying to create a page where I will be getting all the Workitem in the tfs. But I don't know how to Connect to TFS. what reference I need to add currently my code is ( which I get from internet ).
NetworkCredential credential = new NetworkCredential("username", "password");
BasicAuthCredential basicCred = new BasicAuthCredential(credential);
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("https://project.visualstudio.com/DefaultCollection"),
basicCred);
tpc.Authenticate();
Upvotes: 0
Views: 1912
Reputation: 828
First of all, add this library using nuget:
Microsoft.TeamFoundationServer.ExtendedClient
Also you need this namespace, so you should add it to the page:
Microsoft.TeamFoundation.Client
Then you can connect to TFS with following code:
var collectionUri = new Uri("https://project.visualstudio.com/DefaultCollection");
var credential = new NetworkCredential("username", "password");
var teamProjectCollection = new TfsTeamProjectCollection(collectionUri, credential);
teamProjectCollection.EnsureAuthenticated();
Upvotes: 1