- Download the VS TFS SDK (http://msdn2.microsoft.com/en-us/library/bb130146%28VS.80%29.aspx) or install the Visual Studio Team Suite. This will install the necessary assemblies required to access the VS TFS.
- Create a new VS 2005 Project.
- Browse to the following path (
\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies) and add the following references
-using Microsoft.TeamFoundation;
-using Microsoft.TeamFoundation.Common;
-using Microsoft.TeamFoundation.Client;
-using Microsoft.TeamFoundation.WorkItemTracking.Client; - Use the following code to access the VS TFS:
TeamFoundationServer tfs = null;
WorkItemStore wis = null;
tfs = new TeamFoundationServer(tfsName, CredentialCache.DefaultCredentials);
tfs.Authenticate();
// Display the details about the TeamFoundationServer.
richTextBox1.Text = "Team Foundation Server details:";
richTextBox1.Text += " \n Server Name: " + tfs.Name;
richTextBox1.Text += " \n Uri: " + tfs.Uri;
richTextBox1.Text += " \n AuthenticatedUserDisplayName: " + tfs.AuthenticatedUserDisplayName;
richTextBox1.Text += " \n AuthenticatedUserName: " + tfs.AuthenticatedUserName; - To Access the Projects inside the TeamFoundationServer:
wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
//Iterate Through Projects
foreach (Project tfs_project in wis.Projects)
{
treeView2.Nodes.Add(tfs_project.Name);
} - To Access the Workitems in the Projects:
private void treeView2_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
string tfs_projectName = e.Node.Text.Trim(); //The project name
//Perform WIQL Query
WorkItemCollection wic = wis.Query(
" SELECT [System.Id], [System.WorkItemType]," +
" [System.State], [System.AssignedTo], [System.Title] " +
" FROM WorkItems " +
" WHERE [System.TeamProject] = '" + tfs_projectName +
"' ORDER BY [System.WorkItemType], [System.Id]");
foreach (WorkItem wi in wic)
{
TreeNode newnode = new TreeNode();
newnode.Text = wi.Id + wi.Title + "-" + wi.Description;
newnode.Tag = wi;
treeView1.Nodes.Add(newnode);
//treeView1.Nodes.Add(wi.Title + "[" + wi.Type.Name + "]" + wi.Description );
}
Issues: While connecting from home I found that it takes really long, or sometimes times out during performing the following:
wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore))
The solution that I found in the net was :
Go to Internet Exploreer> Connections> LAN Settings
Instead of having a "Detect Proxy Automatically", put in a definite "Proxy setting"