views:

138

answers:

3

I'm implementing a web interface for TFS bug tracking system, so customers can log in and enter bugs. In here I want to add fields according to the template type of the VSTS team project created. For example, a team project created using 'Agile' template has different set of fields than other templates. Therefore I want to identify the process template of the team project at the beginning.

But "Microsoft.TeamFoundation.WorkItemTracking.Client.Project" does not contain a field for template type. So how can I identify the process template type of the team project?

A: 

I don't know the answer to your question, but have some points to make:

  • I edited your question to make clear that you're asking about Process Templates
  • I also clarified that you're talking about Team Projects, and not Visual Studio project files. These two edits together should keep people from thinking you're asking about the things that show up when you use File->Add New Project.

Finally, you should consider that process templates can be customized. You may want to organize around the set of fields, instead of by the template, unless you need information about the template itself.

John Saunders
+2  A: 

The direct answer is to call GetProjectProperties.

However, I agree with John that you may be tackling a harder problem than necessary. Certainly you'd agree that writing a fully generic WIT client is hard. However, work item customization is very common, even within organizations that use a standard process template. So you probably can't get away with a one-off solution, unless you're willing to update it every time a project admin updates their bug template.

Is there some reason WIWA doesn't work for you? (Note that the download link isn't valid anymore; it's now part of the broader TSWA SP1 release.)

Also remember that any such application that's available to customers (not internal staff), whether WIWA or something you write yourself, requires an "external connector license" according to the TFS CAL model.

Richard Berg
A: 

I actually used the following code:

static void GetProjectTemplate()
    {
        string collectionName = "http://<our_host_name>:8080/tfs/defaultcollection/";
        TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(collectionName)
            , new UICredentialsProvider());
        tfs.EnsureAuthenticated();
        ICommonStructureService css = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));
        string[] projects = { "proj1", "proj2", "proj3" };
        foreach (string proj in projects)
        {
            ProjectInfo projectInfo = css.GetProjectFromName(proj);
            String projectName;
            String prjState;
            int templateId = 0;
            ProjectProperty[] projectProperties;


            css.GetProjectProperties(
                projectInfo.Uri, out projectName, out prjState, out templateId, out projectProperties);
            Console.WriteLine(templateId);
        }

        // Locate templateId in the list of Process templates
        IProcessTemplates processTemplates = (IProcessTemplates)tfs.GetService(typeof(IProcessTemplates));
        XmlNode node = processTemplates.GetTemplateNames();
        Console.WriteLine(Regex.Replace( node.InnerXml,"<[A-Za-z]","\n$&", RegexOptions.ECMAScript ) );

    }

...copied and modified from here: http://www.databaseforum.info/30/1083827.aspx

Problem is, I still get '-1' as the template id. Does this mean the projects were created with no template? Also, I changed the project and host names above for posting here. (They are legitimate projects).

warriorpostman