Вопрос

I developed an installer using Wix 3.6 that installs successfully all elements of an application.

Now, each time I give an msi with a higher version, I want the installer to prompt the user to uninstall it. Since now I've tried this:

<Product 
Id="*" 
Name="!(loc.ProductName)" 
Language="3082" 
Codepage="1252"
Version="1.0.1"
Manufacturer="$(var.ProductManufacturer)" 
UpgradeCode="$(var.UpgradeCode)">

<Property Id="PREVIOUSVERSIONINSTALLED" Secure="yes" />
<Upgrade Id="$(var.UpgradeCode)">
  <UpgradeVersion Minimum="1.0.0.0" Maximum="99.9.9.9" IncludeMiminum="yes" IncludeMaximum="no" Property="PREVIOUSVERSIONSINSTALLED" />
</Upgrade>

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

This code successfully uninstalls any previous installed version on my computer. But it doesn't ask the user if he's sure to do so.

What I need is Wix installer to prompt the user saying a message like:

A previous version of your [ProductName] is installed. Do you want to uninstall it? [ Yes | No ] option.

Is there any way to prompt user and check if he really wants to uninstall any previous version?

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

Решение

The Windows Installer Upgrade table has an attribute bit called msidbUpgradeAttributesOnlyDetect that is represented by WiX's UpgradeVersion@OnlyDetect attribute.

When properly authored this causes FindRelatedProducts to set an action property of your choosing with the ProductCode GUID(s) of detected products. It does not pass this off to RemoveExistingProducts for automatic removal though.

While not the typical behavior, there is nothing stopping you from writing some UI that gets triggered when this property has a value. You could ask the user if they want to remove the old version and if yes, set another action property to tell RemoveExistingProducts. (Hint: Author a Upgrade that would never find a product on it's own and hijack it's property to inject the removal. )

If the user says no, you have the choice of aborting the install or continuing the install side by side to a different directory structure. ( Office, Visual Studio et al ).

Другие советы

I found this post useful when solving the same problem. You can use the PREVIOUSVERSIONINSTALLED property you set in the upgrade-tag to open a custom dialog. Do this inside some UI-tags by adding the following code (when using the standard welcome dialog):

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="OldVersionDlg">PREVIOUSVERSIONSINSTALLED</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg">NOT Installed AND NOT PREVIOUSVERSIONSINSTALLED</Publish>

I based my own custom dialog on this Wix tutorial, and ended up with the following code:

 <Dialog Id="OldVersionDlg" Width="260" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
        <Control Id="No" Type="PushButton" X="132" Y="57" Width="56" Height="17"
          Default="yes" Cancel="yes" Text="No">
          <Publish Event="EndDialog" Value="Exit">1</Publish>
        </Control>
        <Control Id="Yes" Type="PushButton" X="72" Y="57" Width="56" Height="17" Text="Yes">
          <Publish Event="EndDialog" Value="Return">1</Publish>
        </Control>
        <Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="30">
          <Text>A previous version of [ProductName] is currently installed. By continuing the installation this version will be uninstalled. Do you want to continue?</Text>
        </Control>
</Dialog>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top