1

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;
        }
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
etuncoz
  • 198
  • 3
  • 7
  • 1
    Have you tried creating project in Team Explorer? In newer versions of DevOps server, we don't use old ISubscriber project, instead, we use the [Subscriptions](https://learn.microsoft.com/en-us/rest/api/azure/devops/hooks/Subscriptions?view=azure-devops-rest-5.0&viewFallbackFrom=vsts-rest-4.1) REST APIs. There is no ProjectCreatedEvent: https://learn.microsoft.com/en-us/azure/devops/service-hooks/create-subscription?view=azure-devops. – Cece Dong - MSFT Jan 08 '20 at 09:42
  • 1
    I thought we couldnt use Team Explorer anymore, doesnt it state here that is not supported for Azure Devops?: https://learn.microsoft.com/en-us/azure/devops/reference/process-templates/overview-process-template-files?view=azure-devops#client-support Rest API idea looks good but I still need to catch that ProjectCreatedEvent and it is not included in the api as you mentioned. Thank you for your comment – etuncoz Jan 08 '20 at 11:09
  • 2
    Creating a project from Team Explorer isn't supported for Azure DevOps Services, but supported for DevOps server. – Cece Dong - MSFT Jan 09 '20 at 05:50
  • @CeceDong-MSFT Would you recommend using `Service Hooks` instead of `ISubscriber`? – roli09 Dec 06 '22 at 13:55

0 Answers0