Как изменить значение по умолчанию «Определенная версия» при добавлении ссылки? - PullRequest
1 голос
/ 15 июня 2010

Когда я добавляю ссылку на свой проект, я обычно хочу использовать Specific Version = FALSE. Это потому, что наша автоматическая сборка установит номер версии. Я вижу, что поведение по умолчанию должно быть ИСТИНА.

Есть ли способ изменить это? В расчете на ручное изменение этого значения возможны ошибки (и в итоге я нарушаю сборку).

Ответы [ 3 ]

2 голосов
/ 19 мая 2011

Создайте проект AddIn и попробуйте:

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
0 голосов
/ 16 июня 2010

Я бы сказал, что вы не должны менять версию сборки при каждой сборке. Для этого вам следует использовать версию файла.

У Сюзанны Кук есть хороший пост в блоге, в котором она подробно объясняется, но это краткое изложение того, что версия файла сборки не обязательно должна совпадать с версией сборки, а для сборок вам необходимо постоянно обновлять версию файла, а не сборочная версия.

Сообщение в блоге Сюзанны Кук

0 голосов
/ 15 июня 2010

Нет способа изменить значение по умолчанию. Если вы используете TFS, вы, вероятно, могли бы применить правило регистрации, но я не уверен, можно ли применить правило регистрации к файлу .csproj или .sln.

...