First of all, your computer must have at least Visual Studio 2012 Update 1 . It includes an updated assembly of Microsoft.TeamFoundation.Client.dll with the BasicAuthCredential class.
Here is the code for this, from the Buck Blog Post How to Connect to the Team Foundation Service .
using System; using System.Net; using Microsoft.TeamFoundation.Client; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { NetworkCredential netCred = new NetworkCredential( "yourbasicauthusername@live.com", "yourbasicauthpassword"); BasicAuthCredential basicCred = new BasicAuthCredential(netCred); TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred); tfsCred.AllowInteractive = false; TfsTeamProjectCollection tpc = new TfsTeamProjectCollection( new Uri("https://YourAccountName.visualstudio.com/DefaultCollection"), tfsCred); tpc.Authenticate(); Console.WriteLine(tpc.InstanceId); } } }
Grant holliday
source share