TFS 2015 server side plugin deployment (using VS 2013)

允我心安 提交于 2019-12-25 08:33:00

问题


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.


回答1:


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;
            }
        }
    }



回答2:


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.



来源:https://stackoverflow.com/questions/39730333/tfs-2015-server-side-plugin-deployment-using-vs-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!