TFS API Part 15: Import Work Item Definition + Validation

12/02/2009

4 comments

TFS API Part 15: Import Work Item Definition + Validation

In my last post TFS API Part 14: Export Work Item Definition we saw how to export specific work item definition from TFS.

In this post I’ll show how to import the work item definition to TFS and how to validate the definition.

 image

Download Demo

First add reference for Microsoft.TeamFoundation, Microsoft.TeamFoundation.Client, Microsoft.TeamFoundation.Common.dll,Microsoft.TeamFoundation.WorkItemTracking.Client.dll
located in – C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\

Add using for:

using Microsoft.TeamFoundation.Proxy;

using Microsoft.TeamFoundation.Client;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

Validate Work Item Definition

        try

        {

            if (string.IsNullOrEmpty(m_projectName))

            {

                WorkItemType.Validate(store, definition);

            }

            else

            {

                WorkItemType.Validate(store.Projects[m_projectName], definition);

            }

        }

        catch (XmlException ex)

        {

            failed = true;

            MessageBox.Show("Xml Exception: \n\n" + ex.Message);

        }

image 

        catch (XmlSchemaValidationException sex)

        {

            failed = true;

            MessageBox.Show("Xml Schema Validation Exception: \n\n" + sex.Message);

        }

image

        if (!failed)

        {

            MessageBox.Show("Validation Complete");

        }

image

Import Work Item Definition

using WorkItemStore to Import the definition:

                

store.Projects[m_projectName].WorkItemTypes.Import(definition);

 image

      

Download Demo

Add comment
facebook linkedin twitter email

Leave a Reply

4 comments

  1. anonymous14/02/2009 ב 00:53

    Definitely, thanks for the great tutorials. I have learned a lot (from don’t even know what TFS to creating apps for TFS in a month).

  2. thomas engen17/03/2009 ב 09:48

    But how do you create a NEW work item with export from another template. For example export Change request from the template (or project) CMMI and import it to MSF agile project?

  3. suraj16/06/2011 ב 11:49

    hi
    can you plz tell me how can I integrat TFS task to MS project 2010