0
votes

I added some custom logic to override the Uninstall method of an MSI. When I add bad code to my Uninstall method the MSI Uninstall bombs. Since the Uninstall bombed I can't remove my software package and try again. So the MSI package installs fine, then I try to uninstall and I see the error of my ways, then I can’t get the thing uninstalled.

I have the following two settings, which seem to work: DetectNewerInstalledVersion False RemovePreviousVersion True

I don’t really need to show the code because I know it’s bad but here it is. Basically if someone adds files to this directory I want to blow them out on uninstall. I also can’t delete InstallerClass.exe because it is being used. When the uninstaller works the entire parent directory is deleted IF it is empty.:

Public Overrides Sub Uninstall(savedState As System.Collections.IDictionary)

        Dim InstallerFileInfo As FileInfo = New FileInfo(Context.Parameters("assemblypath"))
        Dim InstallerDirectoryName As String = InstallerFileInfo.DirectoryName

        Dim ScriptsDirectory As String = (InstallerDirectoryName & "\Directory_to_be_Deleted")
        Dim InstallerClass As String = "InstallerClass.exe"

        If Directory.Exists(InstallerDirectoryName) Then
            For Each foundFile As String In My.Computer.FileSystem.GetFiles(InstallerDirectoryName)
                If (foundFile IsNot InstallerClass) Then
                    My.Computer.FileSystem.DeleteFile(foundFile, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
                End If
            Next
        End If

        'MyBase.Uninstall(savedState)
 End Sub

I have tried many things, such as revving the version and changing my xxVersion switches, but I get no joy.

I would be happy to know the trick to the "uninstall dance", for instance build a known-good version, installing/uninstalling or finding an older known good and installing/uninstalling.

Also, I know that when you use a NEW MSI to uninstall an old one the first thing it tries to do is find and use the InstallerClass.exe from the old version. So obviously it doesn't work because the old version is bad.

Thanks guys!

1

1 Answers

0
votes

You have to edit the MSI in Orca to disable the custom action (InstallExecuteSequence table condition ) and recache it using the command msiexec /I foo.msi REINSTALLMOE=vomus REINSTALL=ALL /qb.

Or you could just reply the snapshot on the VM to back out the install. I'm guessing you now understand that installers should be well tested before installing it on machines you actually care about.