5

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.

kyrylomyr
  • 12,192
  • 8
  • 52
  • 79

1 Answers1

2

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>
kyrylomyr
  • 12,192
  • 8
  • 52
  • 79
  • Another solution is to add the Publish/@Order attribute, and set the first dialog to Order="1" and the second to Order="2". What was likely happening is that both Publish event conditions evaluated to true, and so the MSI installer picked the first Publish action defined. By adding Order, this tells the installer which action to execute if both Publish events have true conditions. One note, the Order event is counter intuitive, and it's actually the higher Order value that is preferred when both conditions are true. You can think of it more as a weight, where the higher weight wins. – pje Aug 03 '15 at 17:45
  • @kirmir Where can I find file WixUI_Wizard.wxs? IT should come with installation of WiX ? I can not find it. Do you know how to make this work with 3.10 version? – grabhints Nov 11 '15 at 20:53
  • @micmica, this file was created manually and it describes the order of dialogs. I used version 3.5, when the question was asked. Don't know about newer version, but I believe there shouldn't be any difference. – kyrylomyr Nov 11 '15 at 23:16
  • @kirmir thank you for answering. Can you please tell me if I need some dll to include, since I get: Unresolved reference to symbol: OldVersionDlg? – grabhints Nov 12 '15 at 16:27
  • @micmica, OldVersionDlg is also my custom dialog. – kyrylomyr Nov 12 '15 at 20:24
  • @kirmir Thank you for answering. Please see : http://stackoverflow.com/questions/33690724/wix-custom-dialog-when-previous-version-exists – grabhints Nov 15 '15 at 11:20