msi-Installer created with Visual Studio and the RemovePreviousVersions-Option

Tags: , ,
Add comments

[Edit: this seems to be solved in Visual Studio 2008. See this article]

In theory if you create a setup project within Visual Studio, you can set the RemovePreviousVersions to force the created setup to uninstall all previous versions of the same software already install on the target computer. This is a very useful option, but it does not work under all circumstances. But before I go into the problems a brief overview how it should work:

Besides the RemovePreviousVersions flag there are two further properties: UpgradeCode and ProductCode. The UpgradeCode must be the same for all setup projects (that is for the old versions and for the new version). The installer uses this UpgradeCode to detect an older version of the software. The ProductCode must be different for every version, this is uses by the installer to detect different versions of the same software . If you change the Version of an installer Visual Studio creates a new ProductCode.

This works the way described here in the same way described in the product documentation as long as you do not use a Version number below 1.0. If you name your beta and prerelease version something like 0.5 the installer does not recognize an previous version and will not uninstall it, but installs the new version side by side which can be a problem for you installation e.g. if it will be installed in the same directory.

Unfortunately this seem to be a known issue since 2004 or earlier and is not fixed in Visual Studio 2005. The installer looks only for previous Versions greater or equal 1.0 but not for versions less than 1.0.

But there is a workaround. You have to patch the MinVersion in the created msi-file with a tool called orca.exe.

  1. Download the Windows Platform SDK – about 400 MB
  2. Install it – Full install is about 1 GB but you only need the MSI-SDK parts, so choose the custom installation.
  3. In the directory of the SDK you will find an orca.msi – install it
  4. Start the orca.exe and open your created msi
  5. Got the Upgrade-Table
  6. Look for the 1.0.0.0 in the VersionMin-field and change it to somethink like 0.1.0.0
  7. Save the changes to the msi

One Response to “msi-Installer created with Visual Studio and the RemovePreviousVersions-Option”

  1. Sabarinath Says:

    Hi Benjamin,
    I have a problem. I have a web setup ( say ver 7.0) installer which is using custom events. Then I create another web setup for ver 8.0 with different ProductCode but same UpgradeCode to upgrade the application from 7.0 to 8.0. But when the ver 8.0 installer is run, the custom events of the 7.0 installer is fired, not the custom events of the 8.0 installer. Can you tell me why this is happening?

    Thanks,

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in