简体   繁体   English

TFS 2015服务器端插件部署(使用VS 2013)

[英]TFS 2015 server side plugin deployment (using VS 2013)

I am using Visual Studio 2013 and wrote a TFS 2015 server side plugin. 我正在使用Visual Studio 2013,并编写了TFS 2015服务器端插件。 Created a local TFS 2015 environment and checked-in files to test it, I found that it works as expected. 创建了本地TFS 2015环境并签入文件对其进行测试,我发现它可以按预期工作。

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. 我想部署我的插件:按照Internet上的说明,我将插件代码的输出路径更改为:.............. \\ Program Files \\ Microsoft Team Foundation Server 14.0 \\ Application Tier \\ Web Services \\ bin \\插件。 So, my plugin.dll and plugin.pdb files are in this location. 因此,我的plugin.dll和plugin.pdb文件位于此位置。

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. 我被卡住了,我试图去Team Explorer->设置-> Source Control(在Team Project下)->签入策略->添加,但是我找不到我的文件。

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. 但是,当连接到部署了插件的TFS服务器的每个客户端都单击“ 签入”按钮时,它将执行。 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. 签入策略与服务器端插件不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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