简体   繁体   中英

TFS 2015 server side plugin deployment (using VS 2013)

I am using Visual Studio 2013 and wrote a TFS 2015 server side plugin. Created a local TFS 2015 environment and checked-in files to test it, I found that it works as expected.

I want to deploy my plugin: Following the instructions on internet I changed my plugin code's output path to : ..............\\Program Files\\Microsoft Team Foundation Server 14.0\\Application Tier\\Web Services\\bin\\Plugins. So, my plugin.dll and plugin.pdb files are in this location.

After this step; I am stuck, I tried to go to Team Explorer -> Settings -> Source Control(under Team Project)-> Check-in Policy -> Add but I wasn't able to find my file.

I need help to deploy my plug-in.

Your server side plugin will not show up in the Check-in Policy Add dialog. It will however execute when the Check In button is hit for every client that connects to the TFS server where the plugin is deployed. Based on the plugin code it will either approve or deny the check-in. In case it denies the check-in you can supply a message for the user about what to fix.

Here is an example that just rejects if the code reviewer is claimed to be GOD. You can also check the comment section and look for required elements if you like.

using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.TeamFoundation.Build.Server;
using Microsoft.TeamFoundation.Common;
using Microsoft.TeamFoundation.Framework.Server;
using Microsoft.TeamFoundation.WorkItemTracking.Server;
using System.Collections.Generic;
using Microsoft.TeamFoundation.VersionControl.Server;

    namespace TFSPlugin
    {
        public class FittingSoftwarePlugin : ISubscriber
        {
            public string Name { get { return this.GetType().Name; } }
            public SubscriberPriority Priority { get { return SubscriberPriority.Normal; } }
            public Type[] SubscribedTypes() { return new[] { typeof(CheckinNotification) }; }

            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
                {
                    var checkinNotificationArgs = notificationEventArgs as CheckinNotification;
                    if (notificationType == NotificationType.DecisionPoint && checkinNotificationArgs != null)
                    {
                        var codeReviewer = checkinNotificationArgs.CheckinNote.Values.FirstOrDefault(v => v.Name.Equals("Code Reviewer"));
                        if (codeReviewer!=null && codeReviewer.Value.Equals("GOD", StringComparison.InvariantCultureIgnoreCase))
                        {
                            statusMessage = "GOD cannot be used as a code reviewer as he is not trustworthy!";
                            return EventNotificationStatus.ActionDenied;
                        }
                    }
                }
                catch (Exception e)
                {
                    // Log error
                }

                return EventNotificationStatus.ActionPermitted;
            }
        }
    }

The check-in policy has to be deployed to the local machines of anyone who is going to use it.

Check-in policies are not the same thing as server-side plugins.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM