Click here to Skip to main content
15,884,473 members
Articles / DevOps / TFS

TFS 2010 Changesets to Changed Assemblies Mapper

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
20 Sep 2011CPOL3 min read 18K   275   3  
TFS 2010: Changesets to changed assemblies mapper
TFS_2010_Changesets_to_changed_assemblies_mapper.jpg

Introduction

This tool is a mash up of different functions to solve a specific real world problem - to map given TFS changesets to the affected assemblies for the purpose of creating service packs.

Background

Our support team engages in creating service packs for our product. Every service pack involves identifying all the .NET assemblies which have been affected as a result of the changes made to the code base for the purpose of the service pack. We use TFS 2010 for version control. The support team wanted a tool to quickly identify the changed assemblies which must make the service pack as a result of certain changesets on TFS. This tool attempts to automate this discovery process.

Using the Tool

The tool needs three pieces of information from the user:

  1. The URL of the TFSProjectCollection - this is in the format of:
    example: http://tfs09:8080/tfs/foo%20-%20900
  2. TFS Folder location within TFS source explorer. This should be the location of the root folder of your source code. This is in the format:
    example: $/Foo 900/Release/2011/2011Staging/Source

    And finally...

  3. Workspace solutions folder. This is the physical folder on your machine which is mapped with the TFS folder above.
    example: C:\Foo Dev\Foo 900\Release\2011\2011Staging\Source

You MUST get the latest on the above TFS folder on your machine prior to running this tool. After all the three pieces of information have been filled up, hit the GetChangesets button. This will launch two threads to get the required information from the system. Once all the information has been obtained, the Get Changed Assemblies button gets enabled and you should see the changesets for the selected TFS branch in the top list view control. Now select the changesets using the check boxes and hit Get Changed Assemblies to get the changes assemblies in the list box below. You can then export the contents of the lower window to clipboard through a context menu.

The workflow for the mapping process is something like this:

Get the changesets for the given branch >> Scan the solution files from the given solution path >> Parse the solution files for the names and paths of the project files >> Parse the project files to get the name of the source files >> Make a dictionary of the source file names as keys and the assembly names as values >> Use this dictionary to map a changset's change object's related file and get the related assemblies. The source files which do not exist in the assemblies are reported separately.

Using the Code

The code is quite easy to read. Please feel free to ask questions.

I have drawn inspirations from the great articles on using TFS 2010 api by Tarun Arora. I also picked up the solutions parser code from John Leidegren's contribution on Stack Trace. The links are provided in the comments section in the source code.

Points of Interest

TFS 2010 API provides great potential to extend existing functionalities as well as gives opportunities to automate manual processes to make life easier.

While playing with Task Parallel Library, I found an interesting fact:

// Found that Parallel.Invoke() blocks the call till 
// all the called functions return. I didn't find it to be suitable for my need.
// Parallel.Invoke(() => GetChangesets(), () => GetFileAndAssemblyInformation());

// So I used Task class instead to achieve asynchrony.
new Task(() => GetFileAndAssemblyInformation()).Start();
new Task(() => GetChangesets(tbTFSProjectCollectionURL.Text.Trim(), 
			tbTFSFolder.Text.Trim())).Start();

History

  • 16/09/2011: First post
  • 20/09/2011: Updated source after a couple of bug fixes

I am waiting for your comments.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Sage UK Limited
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --