We have a custom server side tfs plugin that is deployed under Azure DevOps Server 2019\Application Tier\Web Services\bin\Plugins. There are two subscribers in the plugin, one is subscribed to the WorkItemChangedEvent and the other one is for ProjectCreatedEvent.
WorkItemChangedEvent subscriber is working as expected, unfortunately ProjectCreatedEvent subscriber is not. Tried debugging the code after attaching to the w3wp.exe process, but ProcessEvent method is never being called.
I'm creating a project via browser, using the default project creation wizard.
Am I using the right dll for this event Microsoft.TeamFoundation.Server.ProjectCreatedEvent? Or is it deprecated?
Sharing the sample code below:
Any help would be appreciated.
public class ProjectCreationSubscriber : ISubscriber
{
private static ILog _logger = LogManager.GetLogger(typeof(ProjectCreationSubscriber));
private static readonly string subscriberName = "ProjectCreationSubscriber";
private static Type[] subscribedTypes = null;
private static ControlConfiguration controlConfiguration = null;
private static WorkItemStoreServiceContainer serviceContainer = new WorkItemStoreServiceContainer();
public string Name
{
get
{
return subscriberName;
}
}
public SubscriberPriority Priority
{
get
{
return SubscriberPriority.Normal;
}
}
public Type[] SubscribedTypes()
{
if (subscribedTypes == null)
{
subscribedTypes = new Type[1]
{
typeof(Microsoft.TeamFoundation.Server.ProjectCreatedEvent)
};
}
return subscribedTypes;
}
public EventNotificationStatus ProcessEvent(IVssRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
properties = null;
statusMessage = String.Empty;
try
{
ProjectCreationSubscriber._logger.InfoFormat("PROCESS EVENT! NotificationType:{0}, NotificationEventArgs:{0}", notificationType, JsonUtilities.Serialize(notificationEventArgs));
if (notificationType == NotificationType.Notification && notificationEventArgs is Microsoft.TeamFoundation.Server.ProjectCreatedEvent)
{
var notificationEvent = notificationEventArgs as ProjectCreatedEvent;
//doing stuff here
}
catch (Exception ex)
{
var exceptionInfo = string.Format("Error occured in {0}", this.Name);
ProjectCreationSubscriber._logger.Error(exceptionInfo, ex);
EventLog.WriteEntry(this.Name, exceptionInfo, EventLogEntryType.Error);
//TeamFoundationApplicationCore.LogException(exceptionInfo, ex);
}
Trace.CorrelationManager.StopLogicalOperation();
return EventNotificationStatus.ActionPermitted;
}