Search code examples
visual-studio-2010windows-installersetup-project

Visual Studio Setup project not registering DLL on upgrade


I have made an Outlook add-in and it works fine, I deploy it through an MSI and it registers the DLL correctly.

I've been updating it and incrementing the build number of both the assembly and the setup project equally, however I now have a strange issue when installing the MSI as an upgrade to a previous version.

Install 2.6 works
Install 2.7 works
Install 2.8 works
Upgrade 2.6 -> 2.7 works
Upgrade 2.6 - 2.8 (not sure haven't tried yet)
Upgrade 2.7 -> 2.8 installs files but doesn't register dll
Repair  2.8 after an upgrade install and it registers the dll correctly
Manually register the 2.8 assembly after upgrade install and the plugin works fine.

If I edit the MSI outside of Visual Studio 2010 and change the order of RemovingExistingProducts to be higher up then the 2.7 -> 2.8 install works.

I just don't understand why it isn't registering correctly now.


Solution

  • Still not 100% sure why it worked, then it didn't. However I now have a work around courtesy of somewhere on the internet I forgot to bookmark.

    I add the following VBS code as a post build operation.


    PostBuildEvent

    cscript "$(ProjectDir)fixRemovePreviousVersions.vbs" "$(BuiltOuputPath)"
    

    VBS Script

    Dim objInstaller
    Dim objDatabase
    Dim objView
    Dim objResult
    
    Dim strPathMsi 
    
    If WScript.Arguments.Count <> 1 Then
        WScript.Echo "Usage: cscript fixRemovePreviousVersions.vbs <path to MSI>"
        WScript.Quit -1
    End If
    
    strPathMsi = WScript.Arguments(0)
    
    Set objInstaller = CreateObject("WindowsInstaller.Installer")
    Set objDatabase = objInstaller.OpenDatabase(strPathMsi, 1)
    Set objView = objDatabase.OpenView("UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'")
    
    WScript.Echo "Patching install sequence: UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'"
    objView.Execute
    objDatabase.Commit
    
    WScript.Quit 0