Tfs via IronPython

An example of working with Team Foundation Server from IronPython. (From this blog entry.)

servername = "myServerName" sys.path.append("c:\\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies")

import clr clr.AddReferenceByPartialName("Microsoft.TeamFoundation") clr.AddReferenceByPartialName("Microsoft.TeamFoundation.Common") clr.AddReferenceByPartialName("Microsoft.TeamFoundation.Client") clr.AddReferenceToFile("Microsoft.TeamFoundation.WorkItemTracking.Client.dll")

from Microsoft.TeamFoundation.Server import * from Microsoft.TeamFoundation.Proxy import * from Microsoft.TeamFoundation.Client import * from Microsoft.TeamFoundation.WorkItemTracking.Client import *

tfs = TeamFoundationServerFactory.GetServer(servername)

wis = tfs.GetService(WorkItemStore)

for p in wis.Projects: print p.Name query = "SELECT [System.Id],[System.State], [System.Title] FROM WorkItems \ WHERE [System.State] <> 'Closed' ORDER BY \ [System.WorkItemType], [System.Id]"

workitems = wis.Query(query) for wi in workitems: print wi.Title

Back to Contents.