简体   繁体   中英

Why do I need to specify a new guid for a version upgrade in wix

I've just updated our wix install scripts as per this previous question/answer How to implement WiX installer upgrade? . The idea was to prevent an older version 'downgrading' a newer version. So I have parts of the wix file that look like:

  <Product Id="A_GUID"
    <Upgrade Id="18626be5-521c-4b58-ab8a-54baddf66679">
      <UpgradeVersion
        Property="NEWERVERSIONDETECTED"
        Minimum="$(var.Version)"
        IncludeMinimum="no"
        OnlyDetect="yes"
        ExcludeLanguages="yes"        
        />
     </Upgrade>

     <CustomAction Id="NewerVersionFound" Error="Can't downgrade." />

     <InstallExecuteSequence>
       <Custom Action="NewerVersionFound"
             After="FindRelatedProducts">NEWERVERSIONDETECTED</Custom>
       <RemoveExistingProducts After="InstallInitialize" />
     </InstallExecuteSequence>

I have two versions of this, say 2.1 and 2.2. The current practice is to keep the Product Id Guid (shown as 'A_GUID' above) the same for minor versions (like 2.x) and only to change for major - so moving from 1.x to 2.x we change the Guid.

But, the above doesn't work if the Product Guid is kept the same for 2.1 and 2.2, despite the '$(var.Version)' changing. If I change the Guid, it does work (and prevents the downgrade 2.2 -> 2.1).

I was wondering why this is the case (assuming I'm doing it correctly) - why do we need two bits of information (guid and version) for this to work?

Edit1a: There is an UpgradeCode Guid in the wix, which stays the same for each version. Edit1b: If it's relevant, this is done with an old version of wix (2.x).

Its not related to the product guid.

It is always related to the UpgradeCode you are specify as attribute at the product node.

<Product Id="*" Name="name" Version="$(var.Version)" UpgradeCode="12345678-55F7-4731-A318-772EF75D2830">

Within the upgrade node you are looking to the upgradecode (and not to product guid). You can specify multiply Upgradecodes to find different versions of your software. but upgradecode should normally stay the same in a product. see best practices on MS homepage, please.

    <Upgrade Id="12345678-55F7-4731-A318-772EF75D2830">
        <UpgradeVersion ExcludeLanguages="no" Property="OLDVERSIONFOUND"   
            IgnoreRemoveFailure="yes" MigrateFeatures="no" IncludeMinimum="no"                
            Minimum="0.0.0.0" Maximum="$(var.Version)" IncludeMaximum="no"                
        />
        <UpgradeVersion OnlyDetect="yes" Property="NEWAPPFOUND" IncludeMinimum="yes" Minimum="$(var.Version)" Maximum="99.99.99.99" />
    </Upgrade>

With an custom action (you already have) you react on that.

 <CustomAction Id="OldAppFound" Error="Newer app of [ProductName] is installed" />

Ofcurse you need to schedule the tests for that in the sequences (you also did)

    <InstallExecuteSequence>
        <Custom Action="OldAppFound" After="FindRelatedProducts">NEWAPPFOUND</Custom>
    </InstallExecuteSequence>
    <InstallUISequence>
        <Custom Action="OldAppFound" After="FindRelatedProducts">NEWAPPFOUND</Custom>
    </InstallUISequence>

And if necessary remove the old one (you also have in your code)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM