April 2009 - Posts
Developing an application using the Team Foundation Server Process Template feature is not an easy task, mainly because of the lack of documentation and sample around it.
As I had to deal with it when writing the WITSynchronizer I guess I can share some experience out there.
Using the IProcessTemplates interface
Let's start by the beginning, you have your Team Foundation Server object and want to get the IProcessTemplates interface.
The GetService() method can do that for you:
// Get the Process Template interface
IProcessTemplates ptp = (IProcessTemplates)tfs.GetService(typeof(IProcessTemplates));
The MSDN documentation about this interface is pretty much the list of its members, so let's describe a bit more what you can do with them.
int AddTemplate(string name, string description, string metadata, string state)
This method is used to add a new Process Template in your TFS, it's only the declaration of the new Process Template, the content will have to be upload with another method.
- name: the name of your Process Template (the one you see in the combo box when creating a new Team Project)
- description: the description of your Process Template (the one you see in the description field when creating a new Team Project)
- metadata: the "OuterXML" of the metadata XML element in the ProcessTemplate.xml file of your Template. You can't pull this off manually, you have to take what's come out of the Process Template editor.
- state: I don't know all the possible values, but the "visible" one is the one you want to get your Template correctly.
void AddUpdateTemplate(string name, string description, string metadata, string state, string zipFileName)
This method is used apparently to add a new Process Template (and uploading its content) or updating an existing one.
The first four parameters are the same as the AddTemplate() method.
- zipFileName: the full path and filename of the zipped version of you Process Template folder. Beware that you can't zip this file with WinZip or any kind of Zip Library. The only one I could use successfully is the ICSharpCode.SharpZipLib with the FastZip class.
TemplateHeader[] DeleteTemplate( int templateId)
Delete a template from its ID, you can get the ID calling the TemplateHeaders() method and using the TemplateId field, or by calling GetTemplateIndex().
string GetTemplateData(int methodologyIndex)
This method will download the Template Data as a temporary zipped file and returns you the full path and file name.
So you better have to delete the file once you're done with it!
Basically, unzip the file and you get all the content of your Process Template.
- methodologyIndex: the index can be retrieved calling the GetTemplateIndex() method or using the TemplateHeader structure.
int GetTemplateIndex(string name)
Get the ID of a Template from its name. I guess this method is named incorrectly because what you have in return is the Template's Id.
XmlNode GetTemplateNames()
This method returns an XML Node listing all the Process Templates and their corresponding Id.
TemplateHeader[] MakeDefaultTemplate(int templateId)
Make the Template of the given ID the default one.
TemplateHeader[] TemplateHeaders()
Return an array describing all the Process Template. You will find in this structure all the general information (Name, Description, State, Rank, Metadata, ID)
void UploadMethodology(string filename, int templateId)
Upload a new version of the methodology in an existing Process Template.
- Filename: the full path and file name of the Zipped file containing the content of the Process Template to upload.
- templateId: the ID of the template to update.
My ProcessTemplate class
If you want to do some basic operations with Process Template, you can use the little class I wrote for the WITSynchronizer. It's far from being complete and perfect, but it is easy to use...
You can download the class here.
Construction
You can create a ProcessTemplate instance with three possible ways:
- By giving the directory where the Process Template is stored.
- By giving the zipped file you got by calling GetTemplateData().
- By giving a TeamFoundationServer object and the name of the Process Template.
The class will handle the cleanup of the resource it created (nothing for the first constructor, the directory for the second constructor, the zip file and the directory for the third).
Features
- Get/Set the name and description of the Process Template.
- List all the Work Item Type definitions.
- List all the Work Item Query definitions.
- Get the XML document of a given Work Item Type definition.
- Get the XML document of a given Work Item Query definition.
- Add/update a Work Item Type definition.
- Add/update a Work Item Query definition.
- Upload the Process Template back to the Team Foundation Server.
Travaillant avec beaucoup de client sur le sujet de l'ALM et des méthodologies, je suis souvent confronté à ce genre de situation :
- Je crée un Process Template pour le client, puis je crée un Team Project qui se base sur celui-ci. Le Team Project devient pour l'équipe de développement en quelque sorte le projet de « référence » concernant la méthodologie.
- Le client alors va donc faire évoluer ce Team Project en modifiant la définition des types de Work Item, créant des nouvelles requêtes de Work Items afin de faire évoluer l'implémentation de la méthodologie au sein de l'équipe.
- Tout va bien, mais maintenant que faire si l'on démarre un nouveau Team Project (ou si vous l'avez déjà) et que vous souhaitez que celui-ci bénéficie des évolutions faites sur le projet de « référence » ?
C'est possible, mais ce n'est pas aussi simple et rapide que ca le devrait être… Vous devez exporter les définitions des type de Work Item qui ont changés en local sur votre machine, télécharger le Process Template, remplacer les définitions dans celui-ci, faire de même avec les WIQL (requêtes de Work Item), mettre à jour le fichier « WorkItems.xml » et enfin remonter le Process Template tout beau tout neuf sur le serveur.
Si vous voulez mettre à jour un Team Project existant, l'opération est moins fastidieuse, mais vous devez toujours effectuer les mêmes tâches répétés pour chaque WIT et WIQL, un par un…
Donc comme je n'aime pas trop perdre du temps ainsi que les tâches répétitives, j'ai décidé de développer un petit programme sans prétention, mais qui sera utile pour l'utilisation au quotidien et la maintenance de votre Team Foundation Server.
C'est ainsi que le WITSynchronizer est né !
Je sais, je poursuis toujours ma quête du nom le plus ridicule pour un projet CodePlex, je me demande si j'ai mieux fait qu'avec mon premier "WICreator"! En tout cas j'espère que ce projet le battra en termes de nombre de téléchargements !
Vous trouverez la page d'accueil du projet ici : http://witsynchronizer.codeplex.com.
La première version se télécharge ici.
N'hésitez pas à me donner votre avis !
Voilà à quoi ressemble l'application :
Au passage, je suis particulièrement fier d'une petite fonctionnalité : Unhandled Exception lié à CodePlex !
Si jamais vous rencontrez un problème dans l'utilisation de l'application, un bug par exemple
, vous aurez le dialogue suivant qui apparaitra :
Avec un lien très pratique sur la page « Issue Tracker » de CodePlex qui vous permettra de remplir une fiche de bug !
Bon, comme vous j'espère qu'il y en aura pas trop, mais quand ca se produira, utilisez cette fonctionnalité, je pourrais fixer les bugs rapidement.
Voilà, profitez en bien, et n'oubliez pas que votre avis sera toujours le bienvenue !
Working with many clients on ALM and development processes I am often in a situation like this:
- I create a Process Template for the client and then create a Team Project based on it. The Team Project will become the "reference Team Project", the main one for Process evolution.
- Then the client or I are making modifications on the existing Team Project (modify WIT, add new ones, create new WIQLs) when we want to upgrade the development process.
- Now it's fine, but what happens when you have to start another Team Project (or you already had), and want it to be synchronized with the Work Item Types and WIQL of your "reference Team Project"?
It is possible, but it's not as easy as it should be…. You have to export the WIT and WIQL definition in local, download the Process Template, replace the WIT definition XML files, add new WIT and WIQL, references them in the WorkItems.xml and finally uploading the Process Template back to your Team Foundation Server.
If you want to update a Team Project, the operation is less tedious, but still you have to perform the same set of tasks for each WIT and WIQL, one by one…
So as I don't like to waste time and doing always the same thing, I decided to develop a little program, not a killer featured one, but a useful one for the day to day maintenance of you Team Foundation Server!
Here I present you: the WITSynchronizer!
I know, I'm still running for the "worst CodePlex project name ever" and wonder if it topped my "WICreator" one!
Well, I hope it will top it in download count!
You'll find the project's homepage here: http://witsynchronizer.codeplex.com/.
The first release can be found here.
Don't hesitate to use it and give me feedback!
Here what it looks like:
What feature I'm pretty proud about is the Unhandled Exception one! If you encounter a problem while using the program, a bug for instance J, you'll have the following dialog showing up:
With a nice link to the CodePlex Issue Tracker for you to fill a bug request!
Like you, I hope there won't be too many, but in case there's I expect people to use for me to fix it ASAP.
Enjoy it! And remember, all feedback and thanks are warmely welcome!