I was asked by a colleague to provide a list of all files that were changed under a particular iteration. Rather than delving into the data, I made a couple of API calls to TFS to output a text file with the list.
This is probably not the most efficient method and it is hard coded, but it does output the goods:
Dim tfs As New TeamFoundationServer("http://testtfs01:8080")
Dim store As WorkItemStore = tfs.GetService(GetType(WorkItemStore))
Dim version As VersionControlServer = tfs.GetService(GetType(VersionControlServer))
' Query for work items
Dim query As String = "SELECT [System.Id], [System.Title] " _
& "FROM WorkItems " _
& "WHERE [System.TeamProject] = @Project " _
& "AND [System.IterationPath] UNDER @IterationPath " _
& "ORDER BY [System.Id]"
Dim paramiters As New Hashtable
paramiters.Add("Project", "TestProject1")
paramiters.Add("IterationPath", "TestProject1TestIteration1")
Dim y As WorkItemCollection = store.Query(query, paramiters)
Console.WriteLine(String.Format("Found {0} work items", y.Count))
' Query work items for attachments
Dim wiats = From wi As WorkItem In y, l As Link In wi.Links Where l.BaseType = BaseLinkType.ExternalLink Select l, wi
Console.WriteLine(String.Format("Loading {0} changesets...", wiats.Count))
Dim ChangeSets As New List(Of Changeset)
If Not wiats Is Nothing Then
Dim els = From i In wiats Where LinkingUtilities.DecodeUri(CType(i.l, ExternalLink).LinkedArtifactUri).ArtifactType = "Changeset"
For Each i In wiats
Dim el As ExternalLink = CType(i.l, ExternalLink)
Dim artifact As ArtifactId = LinkingUtilities.DecodeUri(el.LinkedArtifactUri)
If artifact.ArtifactType = "Changeset" Then
Dim cs As Changeset = version.ArtifactProvider.GetChangeset(New Uri(el.LinkedArtifactUri))
ChangeSets.Add(cs)
End If
Next
' ------------------------------
Console.WriteLine(String.Format("{0} changesets loaded", ChangeSets.Count))
Dim files = From f In ChangeSets, c In f.Changes Select c.Item Distinct
Using x = System.IO.File.CreateText("c:Tempfiles.txt")
For Each f In files
x.WriteLine(f.ServerItem)
Next
End Using
End If
If Debugger.IsAttached Then
Console.ReadKey()
End If
As you can see I have very bad naming and layout, but this is a one time use version of the code, so quick and dirty. If I am asked to do this again I would create a proper command line utility, or even a WPF interface to display the data prettily.
Technorati Tags: ALM WIT TFS Custom TFBS Version Control WPF TFS
What to read next
PowerShell TFS 2013 API #2 - Adding to a GlobalList
Learn how to use PowerShell and the TFS 2013 API to automate adding items to a GlobalList by exporting, editing, and re-importing global …
PowerShell TFS 2013 API #1 - Get TfsCollection and TFS Services
Learn how to use PowerShell to connect to TFS 2013, import required assemblies, and access core TFS services like Work Item Store, Version …
Log Elmah errors in Team Foundation Server
Explains how to log Elmah error reports as work items in Team Foundation Server, including attaching error logs, using templates, and …
TFS 2010 Work Item Seed: TFS Work Item system.id at a predefined number
Explains how to use the TFS 2010 API to set the starting Work Item ID by programmatically creating and deleting items, avoiding ID conflicts …
Detecting agile theatre with real delivery signals
Why Most Companies Operating Models Fail in Dynamic Markets
A concise comparison of Predictive and Adaptive Operating Models, explaining why traditional structures fail in dynamic markets and how …
Don’t Manage Dependencies, Remove Them
Explains why dependencies are a sign of poor system design and outlines steps to eliminate them by aligning teams, clarifying ownership, and …
The Estimation Trap: How Tracking Accuracy Undermines Trust, Flow, and Value in Software Delivery
Tracking estimation accuracy in software delivery leads to mistrust, fear, and distorted behaviours. Focus on customer value, flow, and …
Flow of Value vs Flow of Work – Misnomer or Useful Shorthand?
Compares “flow of value” and “flow of work” in Kanban, explaining why only validated outcomes count as value and stressing the need for …
Why Outsourcing DevOps Fails, and How Real Engineering Excellence Starts With Your Team
Avoid DevOps vendor lock-in, discover how true engineering excellence starts with partnership, not outsourcing. Ready to transform your …