Get Files Associated with a Build

Code Snippet, TFS API
One of the greatest features of Team Foundation Server is it's extensibility via the TFS Object Model.  A short while back I received a question asking how to retrieve a list of all files included in all the changesets associated with a build.  The intent (of the person asking the question) was to deploy only those files that had been modified in one of the changesets. The following code example is what I came up with.  I can't say it's the only way, or even the most efficient way, to achieve the desired result, but it's at least one way :-)  I've also posted this example on, here. /// /// Gets a list of files included in all changesets associated with the specified build URI./// /// The name of…
Read More

Creating Team Build Types

Code Snippet, Team Build, Team System, TFS, TFS API
I was answering a question related to programmatically creating team build types today and realized there weren’t too many examples on the web.  I didn’t see any examples that included all the details I was looking for – for example: Adding the solution to be built to the new build type Turning on/off test execution Turning on/off code analysis An example containing these details may exist, I just didn’t come across it during my initial search. So, with that said, I decided to post the main part of the example application I put together to test out some concepts.  The items listed above are included in the example code below. The example code includes two methods: CreateBuildType – this method accepts six arguments that can be used to programmatically create…
Read More

MSDN Code Gallery

Code Snippet
Although it's been about two weeks since Microsoft launched its new MSDN Code Gallery, I am just now getting around to checking it out. At first glance, it appears there are quite a few similarities between the MSDN Code Gallery and Microsoft's CodePlex site (another open source site provided by Microsoft and hosted on top of Team Foundation Server).  So, what are the differences between the two sites?  Basically, it boils down to project management: Microsoft's CodePlex site is suited for open source projects requiring some level of project management whereas the MSDN Code Gallery is mainly an on-line repository of code snippets and example projects (without any of the project management functionality). What I like: The MSDN Code Gallery is a visually pleasing site. Quick and simple site for…
Read More

Programmatically Download Attachments from TFS

Code Snippet, TFS
I created this short snippet of code the other day in reference to a forum question on how to retrieve the linked items for a given work item.  The code below uses the TFS Object Model to retrieve a specific work item (in this case, item #16) and save all attachments to the local file system. Code Snippetusing Microsoft.TeamFoundation.Client;using Microsoft.TeamFoundation.Server;using Microsoft.TeamFoundation.WorkItemTracking.Client;using System;using System.IO;namespace DTTFSLib{public class WorkItemTest {public WorkItemTest(string serverName) {// Connect to the desired Team Foundation Server TeamFoundationServer tfsServer = new TeamFoundationServer(serverName);// Authenticate with the Team Foundation Server tfsServer.Authenticate();// Get a reference to a Work Item Store WorkItemStore workItemStore = new WorkItemStore(tfsServer);// Retrieve a Work Item by ID - in this case, bug #16 WorkItem workItem = workItemStore.GetWorkItem(16);// Get attachments if (workItem != null) { System.Net.WebClient request = new System.Net.WebClient();//…
Read More