I have code to automate the creation of assembly definitions in TFS.
Now I would like this code to be called whenever a branch is created.
Looking at the API, I see that there is BranchObjectCreatedEvent in Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer .
So, I added the code to the console application to handle the event.
private static void MonitorBranchCreated() { try { TfsTeamProjectCollection tfs = InitialiseTfs(); var vcs = tfs.GetService<VersionControlServer>(); var projects = vcs.GetAllTeamProjects(true); foreach (var project in projects) { project.VersionControlServer.BranchObjectCreated += BranchObjectCreated; } Console.WriteLine("Subscribed to TFS BranchObjectCreated Event - Awaiting Notification..."); Console.ReadLine(); } catch (Exception exception) { DisplayError(exception); } } private static void BranchObjectCreated(object sender, BranchObjectCreatedEventArgs e) {
The problem is that the event never fires when I create a branch from Source Control Explorer in Visual Studio.
The MSDN documentation is limited and I cannot find any other use cases, so I hope someone can tell me if this is the right approach.
If so, why cannot this event be fired? If not, is there another way to connect to TFS so that I can handle branch creation events?
source share