Wix: show custom dialog if previous version found

烂漫一生 提交于 2019-12-01 04:28:27

问题


I want to customize my installer to show custom dialog when previous version is already installed: after Welcome dialog user should see a custom dialog OldVersionDlg with information that previous version was found and will be uninstalled automatically.

But for some reason property set by UpgradeVersion element always null when I check it in condition in UI/Publish Dialog.

Here are essential code snippets.

Product.wxs:

<Product Id="*" Version="$(var.Version)" UpgradeCode="$(var.ProductId)"
         Language="1033" Name="$(var.ProductFullName)" Manufacturer="$(var.Manufacturer)">
  <Package Description="$(var.ProductDescription)" InstallerVersion="200" Compressed="yes" 
           Manufacturer="$(var.Manufacturer)" />

  <Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
  <Upgrade Id="$(var.ProductId)">
    <UpgradeVersion Minimum="1.0.0.0" Maximum="$(var.Version)"
                    Property="PREVIOUSVERSIONSINSTALLED"
                    IncludeMinimum="yes" IncludeMaximum="no" />
  </Upgrade>

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

WixUI_Wizard.wxs:

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

The button Next doesn't work. I've checked in logs that PREVIOUSVERSIONSINSTALLED is set after FindRelatedProducts. If I use it in conditions in Product.wxs then everything is OK. But in UI configuration it is always null.

Thanks for any help.


回答1:


The problem was caused by the second line in WixUI_Wizard.wxs. For some reason WiX always uses it. So, to implement checking of previous version we need to exclude PREVIOUSVERSIONSINSTALLED from the second condition:

<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>


来源:https://stackoverflow.com/questions/11734551/wix-show-custom-dialog-if-previous-version-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!