简体   繁体   中英

MSI / Wix installer, install or upgrade

I managed to create a MSI who can install or upgrade my product. But I want to go further and display messages like Your version is already up to date / An upper version is already installed .

In order to do this, I put this in my code :

<Upgrade Id="{{MYGUID}}">
    <UpgradeVersion Minimum = "0.0.0"
                    Maximum = "{{MY_CURRENT_VERSION}}
                    IncludeMinimum="Yes"
                    IncludeMaximum="No"
                    Property="UPGRADEOLDERVERSION"/>

    <UpgradeVersion Minimum = "{{MY_CURRENT_VERSION}}
                   OnlyDetect = "Yes"
                   IncludeMinimum = "Yes" 
                   Property="UPTODATE"/>

    <UpgradeVersion Minimum = "{{MY_CURRENT_VERSION}}"
                    Maximum = "99.99.99"
                    IncludeMinimum="No"
                    IncludeMaximum="No"
                    Property="UPPERVERSIONINSTALLED"/>
</Upgrade>

<Condition Message = "Already up to date">UPTODATE</Condition>
<Condition Message = "Upper version already installed">UPPERVERSIONINSTALLED</Condition>

And it works well. But the thing is that I want the soft to be installed if it's not the case, and by adding theses Condition , whenever I try to install the software, the messages pop up and don't allow me to install the soft, unless I remove theses ones.

The idea is to do something like

if(not installed) 
    # Apply the update rules
else
    install soft

How can I do this ? Thanks !

Keep in mind that you can't install the same MSI twice, just in case that's what your "already up to date" message is about. Anyway, you can't use properties derived from an upgrade as launch conditions because the fact of an upgrade (or not) does not get resolved until the FindRelatedProducts action has run, which is after launch conditions. So your properties have no value (=false) and prevent the install.

The short answer is that I think that if you use the WiX MajorUpgrade element it will do what you want, allowing upgrades but not downgrades. If you don't want to do that, then display your messages (or add them to a dialog) somewhere after FindRelatedProducts has run in the UI sequence.

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