2010-06-15 81 views
1

當我添加一個對我的項目的引用時,我通常希望使用Specific Version = FALSE。這是因爲我們的自動化版本會設置版本號。我看到默認行爲是TRUE。添加參考時如何更改「特定版本」默認值?

有沒有辦法改變它?通過手動更改該值來計算容易出錯(我最終打破了構建)。

回答

0

沒有辦法改變默認值。如果您使用的是TFS,則可以應用簽入規則,但我不確定簽入規則是否可以應用於.csproj或.sln文件。

0

我會說你不應該改變每個版本的程序集版本。您應該爲此使用文件版本。

Suzanne Cooke有一篇很好的博客文章詳細解釋它,但是總結是程序集的文件版本不需要與程序集版本相同,而對於構建,您需要整個時間升級文件版本,不是程序集版本。

Suzanne Cook's blog post

2

創建外接程序項目,並嘗試:

Imports Extensibility 
Imports EnvDTE 
Imports EnvDTE80 
Imports VSLangProj 
Imports VSLangProj80 

Public Class Connect 

    Implements IDTExtensibility2 

    Private _app As DTE2 
    Private WithEvents _RefEvents As ReferencesEvents 

    '''<summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary> 
    Public Sub New() 
    End Sub 

    '''<summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> 
    '''<param name='application'>Root object of the host application.</param> 
    '''<param name='connectMode'>Describes how the Add-in is being loaded.</param> 
    '''<param name='addInInst'>Object representing this Add-in.</param> 
    '''<remarks></remarks> 
    Public Sub OnConnection(ByVal application As Object, ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, ByRef custom As Array) Implements IDTExtensibility2.OnConnection 
     _app = CType(application, DTE2) 
     _RefEvents = CType(_app.Events.GetObject("VBReferencesEvents"), ReferencesEvents) 
    End Sub 

    '''<summary>Implements the OnDisconnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being unloaded.</summary> 
    '''<param name='disconnectMode'>Describes how the Add-in is being unloaded.</param> 
    '''<param name='custom'>Array of parameters that are host application specific.</param> 
    '''<remarks></remarks> 
    Public Sub OnDisconnection(ByVal disconnectMode As ext_DisconnectMode, ByRef custom As Array) Implements IDTExtensibility2.OnDisconnection 
    End Sub 

    '''<summary>Implements the OnAddInsUpdate method of the IDTExtensibility2 interface. Receives notification that the collection of Add-ins has changed.</summary> 
    '''<param name='custom'>Array of parameters that are host application specific.</param> 
    '''<remarks></remarks> 
    Public Sub OnAddInsUpdate(ByRef custom As Array) Implements IDTExtensibility2.OnAddInsUpdate 
    End Sub 

    '''<summary>Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading.</summary> 
    '''<param name='custom'>Array of parameters that are host application specific.</param> 
    '''<remarks></remarks> 
    Public Sub OnStartupComplete(ByRef custom As Array) Implements IDTExtensibility2.OnStartupComplete 
    End Sub 

    '''<summary>Implements the OnBeginShutdown method of the IDTExtensibility2 interface. Receives notification that the host application is being unloaded.</summary> 
    '''<param name='custom'>Array of parameters that are host application specific.</param> 
    '''<remarks></remarks> 
    Public Sub OnBeginShutdown(ByRef custom As Array) Implements IDTExtensibility2.OnBeginShutdown 
    End Sub 

    Private Sub _RefEvents_ReferenceAdded(ByVal pReference As Reference) Handles _RefEvents.ReferenceAdded 
     If pReference.Version <> "0.0.0.0" Then 
      CType(pReference, Reference3).SpecificVersion = True 
     End If 
    End Sub 
End Class