In this article I will show you how to connect to Team Foundation Server and add work item via code
First thing you must install TFS SDK, you can download the Team Foundation Server SDK from the below link.
http://www.microsoft.com/downloads/details.aspx?FamilyID=7e0fdd66-698a-4e6a-b373-bd0642847ab7&DisplayLang=en
Steps:
1- Create windows or web Application
2- Add References for :
Microsoft.TeamFoundation.Client
Microsoft.TeamFoundation.WorkItemTracking.Client
3- The below code will help you to work with Team Foundation Server
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
// declaration variable
private NetworkCredential networkCredential = new NetworkCredential("enter here User Name", "enter here password", "enter here domian");
private Uri uri = new Uri("enter here TFS URL");
string projectName="enter here TFS prject name";
string worktemType = "enter here Work Item Type";
// Set Authentication To TFS
TeamFoundationServer teamFoundationServer = new TeamFoundationServer(uri.AbsoluteUri, networkCredential);
teamFoundationServer.Authenticate();
//Add Work Item
WorkItemStore wis = (WorkItemStore)teamFoundationServer.GetService(typeof(WorkItemStore));
Project tfsProject = wis.Projects[projectName];
WorkItemType wiType = tfsProject.WorkItemTypes[workItemType];
WorkItem workItem = new WorkItem(wiType);
workItem.Title = "Test Work Item";
workItem.Description = "Work Item Description";
workItem.Save();
Very Good and very Helpful
ReplyDeletehow to get all the history of the project?
ReplyDeletemacs8000@yahoo.co.uk.
do u have a code?
I get the error message when I try to 'Authenticate'
ReplyDeleteSystem.Net.WebException = {"The proxy name could not be resolved: 'novalue'"}
Any ideas?
Thanks
For Proxy Error Please check:
ReplyDeletehttp://forums.asp.net/t/992641.aspx
To Get History Please Check The Below URL:
ReplyDeletehttp://blogs.microsoft.co.il/blogs/srlteam/archive/2009/06/14/how-to-get-a-file-history-in-tfs-source-control-using-code.aspx
Can you please let me know that i wana get the Root Folders of my team projects...How can i do that?
ReplyDeleteThe Structure is as follows:
ReplyDeleteTeamProject
1st project
2nd project
3rd project
and so on i have 10 more projects all on same level
I want to know the names of all these projects or their paths in VB.NET...Kindly help ?