Visual Studio 2010 - RemovePreviousVersions

前端 未结 3 1038
天涯浪人
天涯浪人 2020-12-24 09:50

I have a Visual Studio 2010 Deployment Project with the following settings:

DetectNewerInstalledVersion = True
InstallAllUsers = True
RemovePreviousVersions          


        
相关标签:
3条回答
  • 2020-12-24 10:12

    Had same issue with couple of setups migrated form 2005 t0 2010. Edited setup (.msi) file with ORCA and changed the Execute Sequence. RemoveExistingProducts before InstallInitialize This has resolved the installation issue.

    0 讨论(0)
  • 2020-12-24 10:33

    The setup project created with Visual Studio (2008 and 2010) will only replace files if the version number has been incremented. The obvious solution would be to just increment all version numbers; but as you said this is not feasible for you.

    The behavior of the .msi file is basically determined by the moment when the RemoveExistingProducts action is executed. Installers created with VS 2008 schedule this action after the new product has been installed. Modified assemblies whose version has not been incremented therefore don't get replaced. Some more details about the update behavior are described in this thread:

    RemovePreviousVersions=True but previous version is not removed from the target machine

    To change the behavior, you can patch the created .msi file so that the RemoveExistingProducts action is executed before the new product gets installed (this actually has been the behavior if you created the setup with Visual Studio 2005). Patching can e.g. be done using a small VBScript that runs as a post-built step:

    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
    
    0 讨论(0)
  • 2020-12-24 10:34

    The easiest way to perform a complete uninstall before a new installation is to

    1. go to your "startup project", right-click and select "options".
    2. Click on the "assembly information" button. Then increment the "assembly version" and the "file version" values, click "ok".
    3. Then go to your setup project. Ensure that "DetectNewInstalledVersion" is set to true, "RemovePreviousVersion" is true, then increment "version" e.g from 1.0.0 to 1.0.1, and then a dialog box will appear asking you to update your "ProductCode", just select "yes". Make sure you "rebuild" your startup project and then rebuild your setup project.

    This will do the trick. Enjoy. Then "right click" on your setup folder and choose "open folder in windows explorer" and look under the "release" folder.

    0 讨论(0)
提交回复
热议问题