1

I use WiX to create and build my Windows app MSI installer. My Product.wxs file has the following structures to customise the installer, including the display of a custom EULA:

<WixVariable Id="WixUIBannerBmp" Value="MyBanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="MyDialog.bmp" />
<WixVariable Id="WixUIInfoIco" Value="MyIcon.ico" />
<WixVariable Id="WixUILicenseRtf" Value="MyEULA.rtf" />

It uses the 'InstallDir' built-in WiX UI dialog set:

<UI>
  <UIRef Id="WixUI_InstallDir" />
</UI>

This all works fine for fresh installations.

When I release an upgrade to my application, to date, I have been using the following command to execute without a UI it as part of the upgrade process:

msiexec /i MyInstaller.msi REINSTALL=ALL REINSTALLMODE=vemus /passive

I now want to change my EULA, and on the next [minor] upgrade, have the user be asked to agree to the EULA again. How do I do this?

(I removed the /passive switch from the command above and the updater MSI now has a UI, but it does not show the EULA agreement UI – it only does so on a fresh install.)

Ross
  • 4,460
  • 2
  • 32
  • 59
  • 1
    I suggest you make your application show the EULA on first launch instead of messing with this in the setup. This yields a lot more control as well. Beware of showing your dialog underneath other dialogs - a frightening level of support calls can result. – Stein Åsmul Oct 29 '18 at 14:10
  • Yeah that was my backup solution. But I figured it out - see answer. – Ross Oct 29 '18 at 17:36

1 Answers1

1

OK, I eventually figured this out and it was very far from obvious or easy.

By looking at the WiX help files and WiX source files on GitHub, I came up with the solution of populating the MSI "Resume Dialog" (which appears to be used in the case of a minor upgrade) with custom UI constructs to show the EULA and require agreement (mostly copied from WiX's LicenseAgreementDlg).

So, in Product.wxs I added this line to just before the <UI> tag:

<UIRef Id="WixUI_Common" />

Then, within the <UI> tag, I replaced this line:

<UIRef Id="WixUI_InstallDir" />

With this content:

<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="InstallDir" />
<DialogRef Id="BrowseDlg" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<!--<DialogRef Id="ResumeDlg" />-->
<Dialog Id="CustomResumeDlg" Width="370" Height="270" Title="!(loc.ResumeDlg_Title)">
    <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="!(loc.ResumeDlgInstall)" Hidden="yes">
        <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
        <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
        <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
        <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
        <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
        <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
        <Condition Action="show">ALLUSERS</Condition>
        <Condition Action="disable"><![CDATA[UpgradeLicenseAccepted <> "1"]]></Condition>
        <Condition Action="enable">UpgradeLicenseAccepted = "1"</Condition>
    </Control>
    <Control Id="InstallNoShield" Type="PushButton" ElevationShield="no" X="212" Y="243" Width="80" Height="17" Default="yes" Text="!(loc.ResumeDlgInstall)" Hidden="yes">
        <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
        <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
        <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
        <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
        <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
        <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
        <Condition Action="show">NOT ALLUSERS</Condition>
    </Control>
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
        <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
    </Control>
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.LicenseAgreementDlgBannerBitmap)" />
    <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
    <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
    <Control Id="Description" Type="Text" X="15" Y="6" Width="340" Height="32" Transparent="yes" NoPrefix="yes" Text="This Setup Wizard will upgrade the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the Setup Wizard." />
    <Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="UpgradeLicenseAccepted" Text="!(loc.LicenseAgreementDlgLicenseAcceptedCheckBox)" />
    <Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="!(loc.WixUIPrint)">
        <Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
    </Control>
    <Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">
        <Text SourceFile="Resources\EULA.rtf" />
    </Control>
</Dialog>
<InstallUISequence>
    <Show Dialog="CustomResumeDlg" Before="ProgressDlg" Overridable="yes">Installed AND (RESUME OR Preselected)</Show>
</InstallUISequence>
<DialogRef Id="UserExit" />
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
<Property Id="ARPNOMODIFY" Value="1" />

Also, as suggested in my question, I did have to remove the /passive switch from my msiexec call to ensure the UI would be displayed.

Having learned much during the process, I'm conscious there may be another or simpler way to do it, but I'm happy enough with this solution.

Ross
  • 4,460
  • 2
  • 32
  • 59
  • OK, this will obviously not work if deployment is done silently which is the case in all corporate settings. [I have long argued that license dialogs and EULAs should be in the application instead of the setup](https://stackoverflow.com/a/24360658/129130) - maybe have a skim. Obviously also test in all installation modes: `fresh install`, `repair`, `modify`, `self-repair`, `uninstall`, `rollback`, `minor upgrade`, `major upgrade` and with or without `patch packaging`. Sounds like you got this set up. Repair, self-repair should have no dialogs involved - just mentioning these modes. – Stein Åsmul Oct 29 '18 at 19:25