VSS Automation Whitepaper


A customer recently asked,


We are using Visual
SourceSafe for version control for one of our .NET based projects. We are
wondering if SourceSafe can be setup to automatically send out change
notification to a mailing list whenever a file is checked in? We find such a feature useful
and have been using it on our CVS system for a different project.
I searched the SourceSafe documentation, Google and msdn.microsoft.com regarding this and did not
find any relevant information. Could you please confirm if such a setting is possible and if
so how to do that?”


A member of my team responds,


Visual Source Safe exposes an event trapping
model which exposes the before check in and after checkin events. Using this
model one could code a VSS add-in that would send mail notification on each
checkin. There is an article describing event trapping and the IVSS interface at
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvss/html/vssauto.asp"> color=#0000ff
size=2>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvss/html/vssauto.asp


If you’re interested in writing a check in notification
add-in for VSS, you might consider sending your notifications via NET SEND
rather than email. Of course, email is much better if you or the members of your team ever connect to the VSS database remotely.  But NET SEND
is more direct and immediate than emails and the messages won’t
contribute to Inbox bloat (yuk).  I found a nifty C# method that
launches cmd.exe and runs NET SEND programmatically on ASPAlliance.com: href="http://www.aspalliance.com/olson/methods/SendNetSend.aspx">http://www.aspalliance.com/olson/methods/SendNetSend.aspx.


Back to the VSS docs… size=2>Microsoft kann für die Richtigkeit und Vollständigkeit der Inhalte in
dieser Newsgroup keine Haftung übernehmen.

Comments (22)

  1. Philip Rieck says:

    Two points to add:

    1) In VSS, you have to install the application that sends the notification on every client, or check-ins from clients without the app will not send notification (since VSS has more of a client / fileserver arch then client / server) This gets a bit annoying, especially when you update, need to reconfigure, or install a new client

    2) NET SEND is evil. If you don’t have TweakUI, it gets to interrupt you while you work. There’s no history of messages, and they’re limited-length plain text.

  2. Great points. Perhaps we should do something to improve the deployability of client-side administrative add-ins for VSS. I sorta like the modality of NET SEND dialogs though. I agree that the lack of message history is an issue. I’ll post some code for both email and NET SEND notification systems asap. -Korby

  3. Ken Roberts says:

    http://www.sourcevizor.com/ is a commercial product that adds this functionality to VSS

  4. Kevin Greiner says:

    Another possibility would be to use VSS Automation to daily check for changed files and compile a single email contains a list of those files, who checked them in, comments, etc. Come to think of it, that would be pretty handy for us to have! Hmmm……

  5. Victor Soares says:

    I thought this would be a very useful thing to try and implement so I gave it a shot. I tried converting the VB 5 code from the whitepaper to VB.NET but it didn’t work out… probably because I don’t have much vb.net experience.

    When I launch VSS I get a message saying "Error loading SourceSafe add-in: VSSWormPlugin2.Plugin". I have no idea where to look to get a more detailed message.

    Has anybody been able to get this to work?

    Below is my code… maybe somebody can point out where i’m going wrong:

    <PRE>

    Option Strict On

    Imports System.IO

    Public Class Plugin

    Implements SourceSafeTypeLib.IVSSEventHandler

    Dim WithEvents VSSHandler As SourceSafeTypeLib.VSSApp

    Sub Init(ByVal pIVSS As SourceSafeTypeLib.VSSApp) Implements SourceSafeTypeLib.IVSSEventHandler.Init

    VSSHandler = pIVSS

    Dim writer As StreamWriter = New StreamWriter("c:vssPlugin.txt")

    writer.WriteLine("Plugin initiated.")

    writer.Close()

    End Sub

    Function VSSHandler_BeforeAdd(ByVal pIPrj As SourceSafeTypeLib.VSSItem, ByVal Local As String, ByVal Comment As String) As Boolean Handles VSSHandler.BeforeAdd

    VSSHandler_BeforeAdd = True

    End Function

    Sub VSSHandler_AfterAdd(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String, ByVal Comment As String) Handles VSSHandler.AfterAdd

    End Sub

    Function VSSHandler_BeforeBranch(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal Comment As String) As Boolean Handles VSSHandler.BeforeBranch

    VSSHandler_BeforeBranch = True

    End Function

    Sub VSSHandler_AfterBranch(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal Comment As String) Handles VSSHandler.AfterBranch

    End Sub

    Function VSSHandler_BeforeCheckIn(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String, ByVal Comment As String) As Boolean Handles VSSHandler.BeforeCheckin

    VSSHandler_BeforeCheckIn = True

    End Function

    Sub VSSHandler_AfterCheckIn(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String, ByVal Comment As String) Handles VSSHandler.AfterCheckin

    End Sub

    Function VSSHandler_BeforeCheckOut(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String, ByVal Comment As String) As Boolean Handles VSSHandler.BeforeCheckout

    VSSHandler_BeforeCheckOut = True

    End Function

    Sub VSSHandler_AfterCheckOut(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String, ByVal Comment As String) Handles VSSHandler.AfterCheckout

    End Sub

    Function VSSHandler_BeforeRename(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal NewName As String) As Boolean Handles VSSHandler.BeforeRename

    VSSHandler_BeforeRename = True

    End Function

    Sub VSSHandler_AfterRename(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal OldName As String) Handles VSSHandler.AfterRename

    End Sub

    Function VSSHandler_BeforeUndoCheckOut(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String) As Boolean Handles VSSHandler.BeforeUndoCheckout

    VSSHandler_BeforeUndoCheckOut = True

    End Function

    Sub VSSHandler_AfterUndoCheckOut(ByVal Item As SourceSafeTypeLib.VSSItem, ByVal LocalSpec As String) Handles VSSHandler.AfterUndoCheckout

    End Sub

    Function VSSHandler_BeginCommand(ByVal unused As Integer) As Boolean Handles VSSHandler.BeginCommand

    VSSHandler_BeginCommand = True

    End Function

    Sub VSSHandler_EndCommand(ByVal unused As Integer) Handles VSSHandler.EndCommand

    End Sub

    Function VSSHandler_BeforeEvent(ByVal iEvent As Integer, ByVal Item As SourceSafeTypeLib.VSSItem, ByVal Str As String, ByVal Var As Object) As Boolean Handles VSSHandler.BeforeEvent

    VSSHandler_BeforeEvent = True

    End Function

    Sub VSSHandler_AfterEvent(ByVal iEvent As Integer, ByVal Item As SourceSafeTypeLib.VSSItem, ByVal Str As String, ByVal Var As Object) Handles VSSHandler.AfterEvent

    End Sub

    End Class

    </PRE>

  6. Victor,

    One of my developers responded to this query offline with:

    "There was a bug affecting this area that we fixed recently – the plugin name was limited to 31 characters.

    Is it possible that the chosen name for the plugin was longer than ‘VSSWormPlugin2.Plugin’? (this one has only 21 characters)

    Also, the plugin must be registered before using it, so we can co-create the COM object based on its GUID. Did the customer run regsvr32.exe on the dll before running SSExp to add the required registry entries under HKEY_CLASSES_ROOT?"

    Please advise. Korby

  7. Ron Eyink says:

    Has anyone successfully converted the VB5 code from the whitepaper to VB.Net. I am working on a project to automate our build process and this functionality would add great value for the process.

    I have attempted, and what I am seeing is that the Init sub is running fine, but no other function or sub seems to be called. Also the action in VSS (ie Checkout, Checkin, Add . . .) is not performed.

    My code is identical to that from Victor’s post above with the exception I made the plugin name VSS.Plugin. Object is registered and I am able to debug and trap the successful call to the init sub.

    Any ideas?

  8. Nir Livni says:

    Hi,

    Some of our developers also get "Error loading SourceSafe add-in: <name>".

    The length of the name is less than 31 bytes. (about 19 bytes).

    Any news about this one ?

    Thanks,

    Nir

  9. Nir Livni says:

    Hi,

    Some of our developers also get "Error loading SourceSafe add-in: <name>".

    The length of the name is less than 31 bytes. (about 19 bytes).

    Any news about this one ?

    Thanks,

    Nir

  10. Greg Partin says:

    Hi,

    Has anyone figured this out yet? I have written the code in C#, not a COM object and I’m wondering how to let SourceSafe know that the dll is there. I know in the whitepapers I have seen I have to create a file called ssaddin.ini and place <ProgID>=1 in this file but is this the same as with a .NET dll?

    Regards,

    Greg

  11. Enda says:

    Hi,

    I am displaying the VSS Source Safe Database in a tree structure on a C# Form. I can check items in and out but am having trouble Getting Latest Version. Has anyone any ideas ?

    Regards,

    Enda.

  12. What version of VSS are you using and are you attempting a recursive Get or a simple one?

  13. Enda says:

    I am Using VSS version 6, i am using a Simple Get

  14. Hem says:

    Hey,

    I am implementing the VSS events as posted in micorsoft msdn web site, I added Project1.Class1=1 also.

    When I launch VSS it showed me the message, but immediatly it is crashing?

    Did any one can help me…..

    Thanks

  15. Y.Srinu says:

    Any body know how to add a project( folder ) to VSS database programatically?

  16. Very many thanks for a good work. Nice and useful. Like it!

  17. hemainampudi says:

    I am encountering "Invalid Access code (bad parameter)" error when i am performing an archive of restored folders. my current version of VSS is 6.0d. did anybody see this error?