Home Application-development Team Foundation Server 2013 Customization

Team Foundation Server 2013 Customization

By Gordon Beeming
books-svg-icon Book
Subscription
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
Subscription
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
About this book

Team Foundation Server offers you the benefit of having all your data in one system with all tools tightly integrated with each other, making it easier for teams to work together. Knowing how to customize the Team Foundation Server is very useful as well as powerful. Having the knowledge and applying it to TFS can save users many hours as well as make it easier to understand the data in TFS for reporting purposes.

This book will show you how to customize various TFS features in order to create an enhanced experience for your users and improve their productivity. You will create custom controls that will be used in client applications and inside the web access. Next, you will learn how to embed a web page inside your work items to display rich information linked to the work items you are opening.

This book will show you how to modify a team’s process template, and then slowly get to grips with some C# code and create a scheduled job.

Using this book, you will create a JavaScript web access plugin that greatly increases productivity. You will start off by making various modifications to the process template to illustrate how we can cater to custom data requirements, and then we will move towards writing code to perform more complex customizations.

Customizing Team Foundation Server 2013 is one of the best methods you can use to provide rich data for reporting in TFS.

Publication date:
January 2014
Publisher
Packt
Pages
102
ISBN
9781782177142

 

Chapter 1. Customizing the TFS Process Templates for Your Business

In this chapter, we will be looking at extending the TFS process template in the following ways:

  • Customizing the TFS work items using the TFS Power Tools

  • Customizing the TFS work items using raw .xml files

  • Adding a new portfolio to an existing process template

This chapter will assume that you have downloaded the Microsoft Visual Studio Scrum 2013 process template using Visual Studio and saved it to the location C:\ProcessTemplates\. You can see more information on how to do this by going to http://msdn.microsoft.com/en-us/library/vstudio/ff452587.aspx.

 

Prerequisites or tools


To complete all of the examples in this chapter, you will require Visual Studio Professional or higher with TFS Power Tools installed. You can download and install the latest version of TFS Power Tools from http://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f. If you do not wish to perform the customizations using the Process Template Editor in Power Tools, you can use Visual Studio Team Explorer and higher. The Power Tools are a set of enhancements, tools, and command-line utilities that increase the productivity of the Team Foundation Server scenarios; the version used at the time of writing this chapter was 12.0.60919.00.

 

Customizing the TFS work items


Although TFS has many fields that cover a lot of common pieces of data about a work item that teams would want to capture, you often find yourself requiring more fields. In this section, we will be adding two new fields to the Product Backlog item Work Item Type Definition (WITD) at http://msdn.microsoft.com/en-us/library/ms243932.aspx. First, we will add a field using the TFS Power Tools; and then we will add another field using the raw .xml files without using any of the Power Tools GUI.

Adding a new field using the TFS Power Tools

In the example of adding a field with the TFS Power Tools, we will be adding a field for Stream of Work. This field will be a text field that is restricted to the options Website, Email, and Phone Call, and it will be a required field.

We will notice that the following points are important in the creation of this new field:

  • Stream of Work: This will be the name of the field

  • Text Field: This field will be a string field type, so it will support the expected data type

  • Restricted options: This field will make use of the ALLOWEDVALUES element within the field rules, with the allowed values such as Website, Email, and Phone Call

  • Required: This field will need to make use of the Required element in the field rules

To get started with our new field, open the ProductBacklogItem.xml WITD inside Visual Studio 2013 with TFS Power Tools installed, which you should be able to locate in the path C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\TypeDefinitions. When it is open, you should see the following screenshot in your IDE:

ProductBackLog.xml opened using the TFS Power Tools

Click on the New button. This will open up the Fields Definition window. The first tab contains information that is used to identify this field, such as its name, type, whether it is reportable, and help text that is used in the tooltip for the field. The second tab contains all the rules for this tool that are used to determine how this field behaves during the work items workflow.

We are going to use 2 bits from the 4 bits of information that we gathered from our fields' requirements for the details of this field. We are going to use Stream of Work for the Name and Reference Name fields, and then also Text Field which we will translate to being a string data type for this field. Populate the form with the values shown in the following screenshot:

Field Definition details for Stream of Work

It would be a good idea to have some sort of naming convention for the name and reference name of fields, as it's very easy to make a mess with random new fields in TFS. The reference name determines many usages of the field in TFS. For example, the reference name replacing periods (.) with underscores (_) will give you the name of the field in the warehouse if the field is configured to be Reportable, and it is also used to reference this field if it is needed in other parts of the process template. The name values will be used in many other places. For example, when you use the query editor, the names will appear in the fields list as well as in the column header in the grids that display the field.

Note

The field definition name and reference name are unique. If combined with a type other than what's used in other Work Item Definitions (in another collection in the same TFS instance), it can cause your reporting warehouse to stop refreshing. This is because the two different collection definitions will be conflicting, and the refresh job would throw an error.

For more guidelines on Naming conventions for work item tracking objects, go to http://msdn.microsoft.com/en-us/library/ms194941.aspx.

Now, switch to the Rules tab so that we can define the rest of our new field. We are going to add the remaining items from our requirement now. These items are the ones in which the field must have a restricted set of options and must be required. To do this, click on New, then select ALLOWEDVALUES from the list, and then click on OK. Then click on New and enter the value Website. Repeat this step for Email and Phone Call. Your form should look like the window in the following screenshot:

ALLOWEDVALUES options

Next, click on New, select REQUIRED, and double-click on OK. Your rules will look as follows:

Rules for the Stream of Work field

After you click on OK, the new field will be added to the Product Backlog Item WITD. To find out more about the different rules and elements that you can use with a field, see http://msdn.microsoft.com/en-us/library/aa337627(v=vs.90).aspx.

Adding a field to the work item form layout using the TFS Power Tools

Switch to the Layout tab. We will now add this control to the form that is displayed for this work item type. Right click on the first column node in the tree view and click on New Control. In the column options that appear on the right, locate the Label field and type in Stream of Work. Then, select MyCompany.StreamOfWork in Field Name. You can use the Preview Form button to preview an example of the layout of the controls.

Importing a WITD using the TFS Power Tools

That's all that is required to add a new field. To upload this work item type back into TFS, go to Tools | Process Editor | Work Item Types | Import WIT. Then, select your Team Project Collection and click on OK. Click on BROWSE and browse for the ProductBacklogItem.xml file that you have just modified, then select the Team Project you would like to upload this change to, and finally click on OK.

If you create a new Product Backlog Item in the Web Access, you will notice that your change is visible.

Stream of Work in the new Product Backlog Item form

Notice how all the values are listed alphabetically. TFS will automatically display all list items alphabetically.

Adding a new field using the raw .xml files

In the example of adding a field by editing the .xml file, we will be adding a field for Product Code. This field will be a number that will be used to highlight a product code that the work item is related to (if applicable). When any work item for that product code is approved, the product code can't be changed.

We will notice that the following points are important for the creation of this new field:

  • Product Code: This will be the name of the field

  • Number: This field will be an integer field type, so it supports the expected data type

  • When work is approved, the value can't change: This will mean that when a PBI moves into the approved state, we need to lock the value of the product code

To get started with our new field, open the ProductBacklogItem.xml WITD inside your favorite text editor. You should be able to locate it in the path C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\TypeDefinitions.

In the .xml file, find the end of the FIELDS node. Just before it, insert the XML shown as follows:

<FIELD name="Product Code" refname="MyCompany.ProductCode" type="Integer" reportable="dimension" />

We have now defined the name, reference name, and data type for this field.

Adding a field to the work item form layout using the raw .xml files

Next, we need to add the field to the work item layout. Locate the control we added earlier in the chapter, and add a new control below it with the following XML:

<Control FieldName="MyCompany.ProductCode" Type="FieldControl" Label="Product Code" LabelPosition="Left" />

We have now added the field to the layout with a label Product Code.

Altering the work item workflow using the raw .xml files

The next step of meeting the requirements is to make sure that this field is locked when the state is changed to Approved. Find the Approve State in the XML, look for <STATE value="Approved">, and add the following field rule to the FIELD element:

<FIELD refname="MyCompany.ProductCode">
  <FROZEN />
</FIELD>

Our new field will now be locked (frozen) when the state of a PBI changes to Approved for any transition that will be approved. If we only want this to apply from a certain state to be approved, we would add this rule to the transition between the two states.

Importing a WITD using the raw .xml files

The last step will be importing this definition into TFS. Open a Developer CMD console, and then we will use the witadmin tool to import this definition as follows:

cd C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\TypeDefinitions
witadmin importwitd /collection:http://localhost:8080/tfs /p:Demo /f:ProductBacklogitem.xml

You should notice a message that reads The work item type import has completed when the work item type is imported successfully. This will import the file (/f) ProductBacklogItem.xml into the Team Project Collection (/c) at the URL http://localhost:8080/tfs, which is in the Team Project (/p) demo.

When you create a new PBI (or open an existing one), you will see the Product Code field.

New Product Backlog Item with Product Code field

You can also see that after you have changed the state of a work item to Approved, you are not able to alter the Product Code field.

 

Adding a new portfolio to the process template


Lots of companies use different portfolios to categorize and define/understand the scope of work. The default TFS Scrum template contains a Feature, Product Backlog item portfolio. Today, we are going to create a level, Epic, which is above Feature. TFS supports up to seven different portfolio levels.

We aren't going to focus on what fields are available for the new Epic Work Item Type, but rather what is required to add it to our TFS process template.

Creating a new work item type definition

The first step is to create a copy of the existing Feature.xml in the TypeDefinitions folder (C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\TypeDefinitions) and name it Epic.xml. Open the Epic.xml file in your favorite editor. Then locate and change the name attribute on the WORKITEMTYPE node to Epic.

Adding a new portfolio backlog

Now, open the ProcessConfiguration.xml file that is located in C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\Process. In the PortfolioBacklogs node, add the .xml shown as follows:

<PortfolioBacklog category="Microsoft.EpicCategory" pluralName="Epics" singularName="Epic">
  <States>
    <State value="New" type="Proposed" />
    <State value="In Progress" type="InProgress" />
    <State value="Done" type="Complete" />
  </States>
  <Columns>
    <Column refname="System.WorkItemType" width="100" />
    <Column refname="System.Title" width="400" />
    <Column refname="System.State" width="100" />
    <Column refname="Microsoft.VSTS.Common.BusinessValue" width="50" />
    <Column refname="System.Tags" width="200" />
  </Columns>
  <AddPanel>
    <Fields>
      <Field refname="System.Title" />
    </Fields>
  </AddPanel>
</PortfolioBacklog>

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

This XML blurb is the same as the default Features, but with a small change on the first line. We are specifying that this is the Microsoft.EpicCategory category, and we changed the plural and singular names for the work item type to Epics and Epic. You will also need to add the attribute parent="Microsoft.EpicCategory" to the Feature portfolio to state that the new Epic category is the parent of Feature.

You will also need to find the WorkItemColors node and add the following node to specify the color to be used for the Epic work item type.

<WorkItemColor primary="FFFF5900" secondary="FFFFA200" name="Epic" />

This line simply specifies the primary and secondary colors to be used when displaying this work item on the boards and in grids. This helps users of TFS to easily identify a work item by its color, instead of looking for its work item type in the text.

Adding a new work item category

Next, open the Categories.xml file that is in C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking, and add the following XML under the cat:CATEGORIES node:

  <CATEGORY name="Epic Category" refname="Microsoft.EpicCategory">
    <DEFAULTWORKITEMTYPE name="Epic" />
  </CATEGORY>

This will let TFS know that there is an Epic category available and the default work item type for the Epic category is our new Epic work item type.

Importing a new work item portfolio

Importing a new work item or changes made to a work item category will require you to import three files (the ones we just edited). You can accomplish this by opening the Developer Command Prompt for VS2013 and importing the files as discussed in the following sections.

Importing the work item type definition

Importing WITD is the same as what we did earlier. This is a regular import of the WITD using the witadmin tool.

cd C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\TypeDefinitions
witadmin importwitd /collection:http://localhost:8080/tfs /p:Demo /f:Epic.xml

Your new Epic work item type now exists in TFS.

Importing the categories file

We can use the importcategories tool to import categories. This is shown as follows:

cd C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking
witadmin importcategories /collection:http://localhost:8080/tfs /p:Demo /f:Categories.xml

This process will update all category information in TFS.

Importing the process configuration file

We can use the importprocessconfig tool to import the process configuration files as follows:

cd C:\ProcessTemplates\Microsoft Visual Studio Scrum 2013\WorkItem Tracking\Process
witadmin importprocessconfig /collection:http://localhost:8080/tfs /p:Demo /f:ProcessConfiguration.xml

This will import all the process template configuration files into TFS.

 

Summary


In this chapter, we covered adding new fields to an existing WITD, placing these fields in the form layout using the TFS Power Tools, and manually editing the .xml files. We also altered the workflow of an existing WITD by editing the .xml file. If you would like to find out more information on customizing the process template you can go to the following MSDN article http://msdn.microsoft.com/en-us/library/ms243782.aspx.

In the next chapter, we will be looking at how you can increase the Web Access usability by lighting up the dashboard of a team. We will also learn about writing a custom plugin to enhance the portfolio and task board.

About the Author
  • Gordon Beeming

    Gordon Beeming is an energetic and passionate person who always strives to find ways to increase and improve the productivity and friendliness of the systems he works with. He is currently a software developer and does all kinds of TFS administration, customization, and exploring as a sort of a hobby. He is part of the ALM Rangers family and has also been awarded an Microsoft ALM MVP for the past 2 years. Gordon currently works for Derivco, which is a very unique company to work for and is based in Durban, South Africa.

    He has a published book to his credit, called Team Foundation Server 2013 Customization (http://bit.ly/MX0yVb). Also, as part of the ALM Rangers, he has a book to his credit, called Managing Agile Open-Source Software Projects with Microsoft Visual Studio Online (http://bit.ly/1Pppi4g).

    You can find him mainly on Twitter using the handle @GordonBeeming, and he occasionally posts blogs at http://binary-stuff.com/.

    Browse publications by this author
Team Foundation Server 2013 Customization
Unlock this book and the full library FREE for 7 days
Start now