Вопрос

I need that when my installer find something previously installer, it remove all before reinstall. So far I have this code:

<Product Id="GUID1" Name="MyName" Language="1033"
    Version="1.0.0.0" Manufacturer="MyManufacturer" UpgradeCode="GUID2">
  <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

  <InstallExecuteSequence>
    <RemoveExistingProducts Before="InstallInitialize" />
  </InstallExecuteSequence>

  <Feature Id="ProductFeature" Title="MyTitle" Level="1">
    <ComponentGroupRef Id="MyFeatures" />
  </Feature>
</Product>

But when I running the installer I get this message: There is another versino of this product installed. This instalation cannot continue. (or something like this, my windows isn't in english).

How fix that?

Это было полезно?

Решение

If you want, you could use an upgrade code and versioning system to do this:

    <Product Id="*"
         Name="MyApp"
         Language="1033"
         Version="1.0.0"
         Manufacturer="Me"
         UpgradeCode="bf35a656-3e28-4f40-9ebd-566174c9c948">

         <MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of MyApp is already installed. Setup will now exit."/>

         <!-- other stuff -->
    </Product>

Key is you always keep the product code to "*" and the "UpgradeCode" constant. This will make is so that when you change the version to 1.0.1 it will remove all previous versions. However, if a user tries to install an older version when he already has the newer version it won't let him/her (unless they manually uninstall first).

Disclaimer: The same version will not trigger the update. Also changing the 4th number (1.0.0.*) will not trigger an update either. It works just fine with a 3 number versioning scheme. In order to have a four number versioning, I would look into designing a bootstrapper (setup.exe) for the software.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top