Category Archives: 1527

Export TFS Work Items to an .XML file (using TFS Power Tools)

TFS Work Items can be easily exported to XMLSteps:

  1. Download Team Foundation Server Power Tools.

  2. On the command line use the TFPT.exe utility to export all work items from a team project in .XML format:

    tfpt query /collection:<URL> /format:xml /wiql:"SELECT * FROM WorkItems WHERE [System.TeamProject] = ‘<TeamProject>’ AND [System.WorkItemType] <> ‘Sprint’ ORDER BY [System.Id]" > WorkItems.xml

    As you can see I selected all work items from the team project excluding Sprint Work Items. Feel free to modify the query, if necessary.

Publishing Requirements from Word to TFS (via WordToTFS)

This post is part of a blog series:

Steps:

  1. Download and install the freeware tool AIT WordToTFS from here (registration required).

    WordToTFS - ClickOnce installation 

  2. Start Microsoft Word (winword.exe). You should see a new "WordToTFS" ribbon.

    WordToTFS - Ribbon

  3. Choose the layout template you want to use (the names correspond to TFS process templates, but it’s possible to furhter customize those layout templates).

    WordToTFS - Choosing the layout template

  4. Once, you are ready to publish, click ‘Connect‘ on the ‘WordToTFS’ ribbon and choose a team project to connect to.

    WordToTFS - Connect to TFS

  5. Start by creating an outline, headlines, introduction text as you would normally do when creating a requirements document in MS Word.

  6. Once you are ready to add a requirement, choose "Empty Product Backlog Item" (in the case of the "Visual Scrum Scrum" template; the name differs for other process template, e.g. "Requirement" in MSF/CMMI or "User Story" for MSF/Agile).

    WordToTFS - Creating a new requirement in the word document

  7. This will insert a table with the typical fields to describe a requirement. Replace ‘Title’ and ‘Description’ with appropriate values (you can edit those defaults by clicking "Edit Default Values" on the ribbon).

    WordToTFS - Requirement according to the selected layout template

  8. Repeat Steps 5 to 7 for additional requirements.

  9. Once you’re happy with your requirement(s), click ‘Publish‘ in the ‘WordToTFS’ ribbon.

    WordToTFS - Publish 

    WordToTFS - Saving work items in TFS


    WordToTFS - Publishing results
  10. The work item is now created in TFS.
    After publishing the requirement table looks smilar to this:

    WordToTFS - Default work item layout in MS Word 

Notes:

  • Keep in sync: After initially publishing your work items you can either change those in MS Word and re-publish those changes, or change the work items with a different TFS client and click ‘Refresh’ on the ‘WordToTFS’ ribbon to import those changes into your MS Word document.

    WordToTFS - Keeping your document in sync using Refresh 

  • Images: You can insert images in the description field (if the process template is using an HTML-based field) and those will be updated as attachments:

    SupportForImages
  • Test Cases with Test steps: You can enter a numbered list of steps for a Test Case, which will be translated to test steps (as they are required by Microsoft Test Manager):

    SupportTestCases01

    SupportTestCases02

Disclaimer: This MS Word integration is not part of Visual Studio or Team Foundation Server. The plug-in was developed by a Microsoft Partner (AIT) and not by Microsoft itself.

Exporting TFS Work Items to Microsoft Word (via WordToTFS)

This post is part of a blog series:

Steps:

  1. Download and install the freeware tool AIT WordToTFS from here (registration required).


    WordToTFS - ClickOnce installation

  2. Start Microsoft Word (winword.exe). You should see a new "WordToTFS" ribbon.


    WordToTFS - Ribbon 

  3. Choose the layout template you want to use (the names correspond to TFS process templates, but it’s possible to furhter customize those layout templates).


    image_thumb4 

  4. Click ‘Connect‘ on the ‘WordToTFS’ ribbon and choose a team project to connect to.


    WordToTFS - Connect to TFS 

    If the "missing mapping fields" dialog appears, you probably choose the wrong layout template (you can still change it before the next steps). 

  5. Click ‘Get Work Items" from the ribbon.

  6. On the ‘Get Work Items’ pane to the ride, select a stored query.

    WordToTFS - Get Work Items

  7. Click on ‘Find‘ button.
    Optionally, deselect work items in the list if you want to exclude them.

  8. Click on ‘Import‘ button.


    WordToTFS - Importing Work Items


    WordToTFS - Work Items in an MS Word document
  9. Enjoy!

 

Disclaimer: This MS Word integration is not part of Visual Studio or Team Foundation Server. The plug-in was developed by a Microsoft Partner (AIT) and not by Microsoft itself.

Changing the state of multiple work items (command line)

Using the Team Foundation Power Tools (TFPT) you can…


1. Query work items using the command line:


tfpt query /format:id /wiql:”SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = ‘MyProject‘  AND  [System.WorkItemType] = ‘Bug‘  AND  [System.State] = ‘Active‘  AND  [System.Reason] = ‘New‘” /collection:http://servername:8080/tfs


2. And by adding the pipe command you can change the work items returned by the query:


(… command from above …) | tfpt workitem /update @ /fields:”State=Resolved;Reason=Fixed

Setting Remaining Work to Zero when closing a work item in TFS

Question:

How can I make sure that the "Remaining Work" field is set to 0 when the work item is closed (for example when associating a work item during checking-in)?

Short Answer:

You can achieve this using the <COPY> rule on the transition to the "Closed" state.

Step-by-Step instructions:

  1. For the desired transition (in this example from "Active" to "Closed").

    Edit the Workflow Transition with Process Template Editor (part of TFS Power Tools)

  2. Add a field reference to "Microsoft.VSTS.Scheduling.RemainingWork"

    Choose the desired field 
  3. Add a new rule of type "COPY"

    You can use the copy rule to set values
  4. Choose From = "value" and enter value = "0"

    The copy rule sets a value to a field
  5. The resulting XML should look something like

     XML under the covers defines our new rule
  6. Verification: After transitioning a task work item from "Active" to the "Closed" state "Remaining Work" is set to zero.

    Work Item History shows the new rule in beeing applied on the state transition. 

Tool for creating direct links to TSWA

Buck Hodges from Microsoft blogged about all the possible links you can construct to point to TSWA pages.

For example the following URL opens the Work Item Editor:

Open the existing work item with ID 1234: http://mytfs:8090/wi.aspx?id=1234

To make it simple I created a small tool that helps you construct those URLs in an easy way:

Team System Web Access Link Creator

You can download the source from here:

File Attachement: WebAccessLinkCreator.zip

Using rich HTML descriptions instead of plain text

Objective

Allow rich HTML formatting in description fields of the MSF Agile process template.

Note: The MSF CMMI process does support HTML formatting by default. In order to use it you have to enable the formatting toolbar (see Step 6 below).

Work Item Customization

Step 1: Add a new HTML description field

Since the System.Description field is defined of type string as opposed to type HTML we need to create a new field:

2AddNewField

3AddNewField

Step 2: Change the work item layout

Use your own HTML field instead of System.Description

4EditLayout

Step 3: Refresh Work Item cache

Right-click "Work Items" in Team Explorer and select "Refresh".

5RefreshWIs

Step 4: Enable the formatting toolbar

Right-click on the Visual Studio toolbar, find and click "Formatting":

6EnableFormattingToolbar

A new toolbar will appear:

7FormattingToolbar

Result

Click into the description field and use the toolbar to format your input:

8UsingRichFormatting

 

Optional Step 5: Copying the old descriptions to the new HTML field

It would be a pity to loose the existing descriptions so let’s write a small utility using the Team Foundation Object model to copy the "old" descriptions to the new HTML field:

static void CopyOldDescriptions()
{
    // TODO: Change these values:
    string tfsName = "servertogo";
    string tfsProjectName = "WorkItemCustomization";
    string tfsHtmlDescriptionFieldName = "DescriptionHtml";
    string tfsWorkItemType = "Task";

    using (TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsName))
    {
        WorkItemStore wit = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
        WorkItemCollection result = wit.Query(String.Format("SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = '{0}' AND [System.WorkItemType] = '{1}'", tfsProjectName, tfsWorkItemType));
        List<WorkItem> affectedWorkItems = new List<WorkItem>();
        foreach (WorkItem wi in result)
        {
            if (wi.Description.Length > 0)
            {
                // Set new description
                string value = (string)wi[tfsHtmlDescriptionFieldName];
                if (String.IsNullOrEmpty(value))
                {
                    wi[tfsHtmlDescriptionFieldName] = wi.Description.Replace("\n", "<br>");
                }
                else
                {
                    wi[tfsHtmlDescriptionFieldName] += "<br><p>Old description:</p><p>" + wi.Description.Replace("\n", "<br>") + "</p>";
                }

                // Delete old description
                wi.Description = String.Empty;

                affectedWorkItems.Add(wi);
            }
        }

        if (affectedWorkItems.Count > 0)
        {
            wit.BatchSave(affectedWorkItems.ToArray());
            MessageBox.Show("Items updated: " + affectedWorkItems.Count);
        }
        else
        {
            MessageBox.Show("Nothing to do.");
        }
    }
}


Happy formatting. :-)



 



A very Basic Process Template to start with

If you want to start small with your team project you might consider the “Basic Process Template” instead of the built-in MSF Agile and MSF CMMI process templates. It can find on MSDN. From the description:

The basic process template includes:

  • one work item type: bug,
  • three queries: AllWorkItems, MyWorkItems, and MyWorkItemsAllTeamProjects,
  • a basic Windows SharePoint Services team portal (created from the default site template),
  • and a SQL Server 2005 Reporting Services site that has the following reports on it: Builds, Bug Rates, Quality Indicators, Tests Failing Without Active Bugs and Load Test Summary.

Use this process template as a basic starting point and an alternative to the MSF for Agile Software Development or the MSF for CMMI Process Improvement templates.

Step 1: Upload the process template to your TFS

Step 2: Create a new team project (using the new process template)

Step 3: Discover what’s been created

Link: http://msdn.microsoft.com/en-us/library/ms194993(VS.80).aspx