Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Perform a custom action for Check-in event in Microsoft Team Foundation Server

0.00/5 (No votes)
17 Mar 2013 2  
Perform a custom action for Check-in event in Microsoft Team Foundation Server.

Introduction 

Microsoft Team Foundation Server is a very powerful and customizable tool user of version control. TFS 2005 is less stable when compared to TFS 2008.

Background 

Now I just faced a legitimate requirement..

When someone checks-in any file to the TFS, I need to get the list of files checked-in and perform a custom action based on that file(s) list. How do I do that??  I just need to extend the Microsoft TFS services. 

Using the code

TFS is nothing but a SQL Server database(s) and a Share Point Web Service. All actions to the TFS are done by calling webservices at http://yourservername:8080/…asmx. So what you need to do is listen for a particular event and then catch it and execute your code. 

BuildCompletionEvent NodesDeletedEvent
BuildStatusChangedEvent ProjectCreatedEvent
BranchMovedEvent ProjectDeletedEvent
NodeCreatedEvent CheckinEvent
NodePropertiesChangedEvent WorkItemChanged
NodeRenamedEvent

You can find the BisSubscribe.exe at –> C:\Program Files\Microsoft Visual Studio 2005 Team Foundation Server\TF Setup\.

TFS has a small interesting utility called BisSubscribe.exe, you can use this tool to subscribe to quite a few events in TFS. So, now i want to subscribe to the TFS Checkin-Event, and the command goes like this:

BisSubscribe.exe /server tfsserver01 /eventType CheckinEvent /deliveryType Email /address vinubaby1@gmail.com

This will create a subscription on the tfsserver01 server for CheckIn event and a email will be sent to vinubaby1@gmail.com, but this does not serve my requirement. I need a list of files checked-in the moment it is checked in. So, i just tweak the command like this.

BisSubscribe.exe /server tfsserver01 /eventType CheckinEvent /deliveryType Soap /address http://myserver:81/service.asmx

This command will create a subscription on tfsserver01 server for Checkin event and will invoke the Notify() method in the service.asmx webservice which i developed and published in http://myserver:81/

The webservice will have the Notify command with the following signature:

[SoapDocumentMethod(Action = "http://Microsoft.VisualStudio.Bis/Notify", 
         RequestNamespace = http://Microsoft.VisualStudio.Bis)] 
[WebMethod] 
public void Notify(string eventXml) 
{ 
     //Write your custom code here 
     //Use eventXml to extract event related fields and their values 
}

The signature of the Notify function should be same as above.

Happy programming….. Enjoy.. 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here