Connect TFS Through C#

Create a C# console application from Visual Studio.

Add references to the following assemblies

  • Microsoft.TeamFoundation.Common
  • Microsoft.TeamFoundation.Client

I am using TFS 2013 & Visual Studio 2015 , so local path of DLLs are on following

C:\program files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer

You can use nuget packages also for these dlls

Install-Package Microsoft.VisualStudio.Services.InteractiveClient -Version 14.89.0
Install-Package Microsoft.TeamFoundationServer.Client -Version 14.89.0
Install-Package Microsoft.TeamFoundationServer.ExtendedClient

Just copy paste the following program, and have the TFS reference programically

using System;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Client;

namespace TfsApplication
    class Program
        static void Main(String[] args)
            var collectionUri = new Uri("http://SERVERIP:8080/TFS/SITECOLLECTIONNAME");
            TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(collectionUri, new NetworkCredential("USERNAME", "PASSWORD", "DOMAIN"));            
            // your generic code

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s