Get TemplateId of Project in TFS

I’m trying to get the process template used to create a project in TFS.

I use this code. where "server" is an instance of TemFoundationServer class

css = (ICommonStructureService)server.GetService(typeof(ICommonStructureService));
string projectName, projectStatus;
int projectTemplate;

ProjectProperty[] projectProperties;

//Obtener la lista de proyectos disponibles.
foreach (ProjectInfo projectInfo in css.ListAllProjects())
{
css.GetProjectProperties(projectInfo.Uri,
out projectName, out projectStatus, out projectTemplate, out projectProperties);

MessageBox.Show(Convert.ToString(projectTemplate), "Template Id");

}

But in the message the Template Id always return "-1"

Is this a Bug , or I’m missing something.
or is there another way to know the process templete of a project in tfs

Thanks.




Answer this question

Get TemplateId of Project in TFS

  • Coolerbob

    I m using the RC version, and it was updated from Beta 3.

    I wasnt thinking about changes in the template.
    Thanks.

    Anyway, which TFS version are you using

    Thanks again.



  • Tony N

    Your snippet of code works fine against my server. I get a template Id of 1 for Agile and 2 for CMMI. The -1 return value is telling you that the template_id column in the TfsIntegration.dbo.tbl_projects table is null. Is that what you see when browsing with SQL Server Management Studio

    Are you running Beta 3 Refresh bits or an RC build If RC, was it a new installation or an upgrade from B3R

    Can you share the reason why you are trying to tie an existing project back to the template id Once the project is created, the template contents may change and invalidate the kind of connection you are trying to make.


  • Arno3456

    I am using an RC build.

    I've confirmed that the B3R project creation code did not update template_id. That is why you see a -1 for projects created under B3R. If you create a new project with your upgraded RC bits, you should see a value other than -1 for projectTemplate in your sample.


  • Get TemplateId of Project in TFS