2016-09-27 102 views
0

我使用Visual Studio 2013並編寫了TFS 2015服務器端插件。創建一個本地TFS 2015環境並簽入文件來測試它,我發現它按預期工作。TFS 2015服務器端插件部署(使用VS 2013)

我想部署我的插件:按照互聯網上的說明,我將插件代碼的輸出路徑更改爲:.............. \ Program Files \ Microsoft Team Foundation Server 14.0 \ Application Tier \ Web Services \ bin \ Plugins。所以,我的plugin.dll和plugin.pdb文件在這個位置。

經過這一步;我被卡住了,我試圖去團隊資源管理器 - >設置 - >源代碼管理(在團隊項目下) - >簽入策略 - >添加,但我無法找到我的文件。

我需要幫助來部署我的插件。

回答

2

您的服務器端插件不會顯示在簽入策略添加對話框中。但是,當連接到部署插件的TFS服務器的每個客戶端都會點擊Check In按鈕時,它會執行。根據插件代碼,它會批准或拒絕簽入。如果拒絕簽入,您可以向用戶提供有關要修復的內容的消息。

這是一個例子,如果代碼審查者被聲稱是上帝,就會拒絕。您也可以查看評論部分,並根據需要查找所需的元素。

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

解釋真的很好,謝謝。 –

1

簽入策略必須部署到任何要使用它的人的本地機器上。

簽入策略與服務器端插件不同。

+0

正如我所說的,我有一個本地TFS,我試圖將它部署在我的機器上。我無法編寫服務器端插件來強制用戶輸入特定的提交消息嗎?例如;我希望提交消息包含問題編號。可能嗎? 如果你知道它是如何工作的,你可以驅動我通過這個過程,請 –