Click here to Skip to main content
11,928,919 members (56,505 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked

Working with TFS Server

, 23 Jun 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Working with TFS Server using TeamExplorer SDK.


I've worked on a project that must have the ability to integrate with Team Foundation Server. I tried to search CodeProject, but unfortunately found only one article concerning this. I was quite confused about the topic, but got it all clear - there is a very good documentation of TFS programming in MSDN. So, in my post, I'll outline links to the source information and will present a short piece of code for novice developers.

Before starting

  • Ensure that you have installed Visual Studio 2005 SDK (see links below).
  • The simplest way is to use GAC.

  • Add references to the TeamFoundation assemblies.
  • Screenshot - TFS.gif

Working with TFS

This is an example of how to connect to a TFS server, and retrieve Projects and their WorkItems using WIQL (WorkItem Query Language, see links):

// Using Section

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client; 

public void WorkWithTFS(string login, string password, string tfsName)
    //Connecting Server
    NetworkCredential tfsCredential = new NetworkCredential(login, password);
    TeamFoundationServer tfs = new TeamFoundationServer(tfsName, tfsCredential);

    WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

    //Iterate Through Projects
    foreach (Project tfs_project in wis.Projects)

       //Perform WIQL Query 
       WorkItemCollection wic = wis.Query(
          " SELECT [System.Id], [System.WorkItemType],"+
          " [System.State], [System.AssignedTo], [System.Title] "+
          " FROM WorkItems " + 
          " WHERE [System.TeamProject] = '" + tfs_project.Name + 
          "' ORDER BY [System.WorkItemType], [System.Id]");
       foreach (WorkItem wi in wic)
         Console.WriteLine(wi.Title + "["+wi.Type.Name+"]"+wi.Description);

You can also use Queries stored on the TFS server to retrieve WorkItems.

Also, the TFS SDK allows you to completely manage the TFS Server; for more information search MSDN.



  • 23 June 2007: First version.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Petro Protsyk
Netherlands Netherlands
Please visit my website for more articles

I'm software developer & Ph.D. student

You may also be interested in...

Comments and Discussions

GeneralThoughts Pin
PIEBALDconsult10-Dec-14 19:13
protectorPIEBALDconsult10-Dec-14 19:13 
GeneralThanks, concise and to the point. Pin
edger27-Apr-10 18:40
memberedger27-Apr-10 18:40 
GeneralCannot pass a GCHandle across AppDomains. Pin
naveensri23-Apr-08 1:16
membernaveensri23-Apr-08 1:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 23 Jun 2007
Article Copyright 2007 by Petro Protsyk
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid