BranchFormated TFS API related event does not fire

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) { // Create the Build } 

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?

+4
source share
1 answer

When events are connected to the client API, you receive only events generated by this client . If you connected the BranchObjectCreated , then call VersionControlServer.CreateBranch() then , which the branch object you created will be called.

If you want to listen to events on the server (for example, when someone else creates a branch or you create a branch from another client), you need to connect to the server’s project warning system.

You can install Explorer Alerts in Team Foundation Server Power Tools , which allows you to set up small-scale alerts for projects that will send you an email or a web method call. At this point, you can create a new assembly that references this new branch.

+4
source

Source: https://habr.com/ru/post/1381498/


All Articles