How to skip InstallDir Dialog on upgrade - wix

I would like to supress the InstallDirDlg on upgrade. But my approach doesn't work.
I tried to skip the InstallDirDlg using
<Publish Dialog="InstallDirDlg" Control="Back"
Event="NewDialog" Value="WelcomeDlg">NOT Installed</Publish>
I tested it by installing Version 1.0.0.0 and then Version 1.0.1.0 but the InstallDirDialog still shows up.
I'm quite new to WiX so maybe I'm missing something.
Here's the Product.wxs file contents:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyApp" Language="1031"
Version="1.0.1.0" Manufacturer="Abid"
UpgradeCode="8dc49e86-c23a-4541-bef2-259bdec14a57">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<UI>
<UIRef Id="WixUI_InstallDir" />
<Publish Dialog="WelcomeDlg" Control="Next"
Event="NewDialog" Value="InstallDirDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog"
Value="WelcomeDlg">NOT Installed</Publish>
</UI>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<Property Id="INSTALLDIR">
<RegistrySearch Id="ProgramRegistry" Type="raw" Root="HKCU"
Key='Software\[Manufacturer]\[ProductName]'
Name='InstallDir' />
</Property>
<MajorUpgrade DowngradeErrorMessage="Eine neuere Version von [ProductName] ist bereits installiert." />
<MediaTemplate EmbedCab="yes" />
<!-- ... --->
</Wix>

Can you try using NOT OLDERVERSIONBEINGUPGRADED instead of NOT Installed?
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">NOT OLDERVERSIONBEINGUPGRADED</Publish>

NOT Installed won't work since the newer Version, the upgrade itself isn't installed.
If you use the MajorUpgrade element the property
WIX_UPGRADE_DETECTED
should evaluate to true on an upgrade, so try using NOT WIX_UPGRADE_DETECTED in your condition.
As far as I know UPGRADINGPRODUCTCODE and PREVIOUSVERSIONSINSTALLED may also sometimes be set on an upgrade, but those aren't necessarily as reliable.

This might be an old post, but I recently ran into the same problem and couldn't find a solution here that really works.
As LeonardDM said I had to use the WIX_UPGRADE_DETECTED, yet this alone didn't do the trick.
Just in combination with the Order attribute of Publish it really skipped the InstallDirDlg on Updates:
<Publish Dialog="WelcomeDlg"
Control="Next"
Event="NewDialog"
Value="InstallDirDlg"
Order="5">NOT WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="WelcomeDlg"
Control="Next"
Event="NewDialog"
Value="VerifyReadyDlg"
Order="2">WIX_UPGRADE_DETECTED</Publish>
Hope this helps anyone still searching.

Related

Prevent downgrading from a bundle

before I would just use 1 wxs project file to install my app. This would uninstall all previous versions before installing.
Now I have added a bundle and it no longer works. If I change the setup file like adding another file or registry setting and attempt install it will create another entry in my program and features list.
How can i get the same action/behavior from a bundle?
This snippet is what is inside my Product wxs file:
<MajorUpgrade
AllowDowngrades="no"
AllowSameVersionUpgrades="no"
IgnoreRemoveFailure="no"
DowngradeErrorMessage="loc.NewerVersionInstalled"
Schedule="afterInstallInitialize"/>
<InstallUISequence>
<Custom Action='PreventDowngrading' After='FindRelatedProducts'>NEWPRODUCTFOUND</Custom>
</InstallUISequence>
<CustomAction Id='PreventDowngrading' Error='Newer version already installed' />
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONROOTDIRECTORY" />
<UI>
<UIRef Id="WixUI_Minimal" />
<Publish
Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed
</Publish>
</UI>
thanks

Uninstalling Bundle causes msi to install

I have two Wix projects - one that creates the MSI and the other that bootstraps it into an exe.
Using the exe, I can install the application with no issues, but when I try to uninstall the application, I get my installer's setup menu again and it attempts to install itself again.
If I cancel the re-install, and attempt to uninstall again, it works as expected.
If I perform the same workflow with the msi, it works as expected.
Here's what my bootstrapper looks like:
<Bundle Name="name" Version="2.0.0.0" Manufacturer="company" UpgradeCode="guid" IconSourceFile="icon.ico" DisableModify="yes">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication LicenseFile="license.rtf" SuppressOptionsUI="yes" SuppressRepair="yes" />
</BootstrapperApplicationRef>
<Chain>
<MsiPackage SourceFile="application.msi" DisplayInternalUI="yes" EnableFeatureSelection="yes"/>
</Chain>
</Bundle>
Any ideas?
Update
As per suggestions, I've modified my bundle to the following (set EnableFeatureSelection to no), but it's still showing the same behavior.
<Bundle Name="name" Version="2.0.0.0" Manufacturer="company" UpgradeCode="guid" IconSourceFile="icon.ico" DisableModify="yes">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication LicenseFile="license.rtf" SuppressOptionsUI="yes" SuppressRepair="yes" />
</BootstrapperApplicationRef>
<Chain>
<MsiPackage SourceFile="application.msi" DisplayInternalUI="yes" EnableFeatureSelection="no"/>
</Chain>
</Bundle>
Update #2
I noticed that when I uninstall for the first time and it launches the install setup, if I cancel the setup, it fails, but it has already removed all the files and registry keys. Running the uninstall the second time removes the entry from the Add/Remove programs (successfully).
Update #3
Here's the UI sequence for the msi
<UI>
<DialogRef Id="WelcomeDlg"/>
<DialogRef Id="LicenseAgreementDlg"/>
<DialogRef Id="VerifyReadyDlg"/>
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="UserExit" />
<DialogRef Id="SelectDbDlg" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg"></Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">NOT Installed</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SelectDbDlg">NOT Installed</Publish>
<Publish Dialog="SelectDbDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
<Publish Dialog="SelectDbDlg" Control="Next" Event="NewDialog" Value="DbCreateCredDlg">NOT Installed</Publish>
<Publish Dialog="DbCreateCredDlg" Control="Back" Event="NewDialog" Value="SelectDbDlg">NOT Installed</Publish>
<Publish Dialog="DbCreateCredDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg">NOT Installed</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="DbCreateCredDlg">NOT Installed</Publish>
<Publish Dialog="SetupTypeDlg" Control="Next" Event="NewDialog" Value="FeaturesDlg">NOT Installed</Publish>
<Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="FeaturesDlg">NOT Installed</Publish>
<Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">NOT Installed</Publish>
<Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">NOT Installed</Publish>
<Publish Dialog="FeaturesDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg">NOT Installed</Publish>
<Publish Dialog="ExitDialog" Control="Back" Event="EndDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
</UI>
This sounds like there is an issue with the MSI. Since you have DisplayInternalUI="yes", the UI belonging to the MSI is what you see when the application is being added or removed. My guess is that there is some issue with the order in which the MSI install dialogs are being displayed, or with the conditions on which the MaintenanceTypeDlg dialog is displayed. Without seeing the options set on the MSI, or the publish order for the UI dialogs and the conditions under which they are displayed it is hard to say where the problem lies specifically. An example of what your UI fragment for the MSI looks like would help further diagnose if this is the issue.
----Edit----
As I expected the only path for your UI to follow is the install path, and the condition on the WelcomeDlg element forces it down that path. To fix this, remove the current WelcomeDlg and replace with the following two lines:
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed AND NOT PATCH</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
This will use the bootstrapers welcome screen to determine if the user wants to uninstall and, since there is no Installed condition to publish the VerifyReadyDlg, skip right to the unistallation without publishing any of the MSI's UI dialogs. This appears to be what you are looking to do, however, if you did want to set a sequence of dialogs in the MSI to guide the user through the uninstall, you could add those dialogs here.
After a couple more days of poking at it, I found the problem and it was due to the MSI throwing an error upon uninstall (silently). I have some custom actions defined, but I did not have them set to run only upon install.
So I had this before:
<InstallExecuteSequence>
<Custom Action="ServerName.Set" Before="AdjustConfigurationFile"/>
<Custom Action="AdjustConfigurationFile" Before="InstallFinalize"/>
<Custom Action="CreateDatabase" After="InstallFinalize"/>
</InstallExecuteSequence>
Upon uninstall though, the custom action would run to adjust the configuration file (which would fail becaue the file no longer exisited) which would cause the application to rollback, which would cause the installer to run again.
Changing the Install sequence to the following fixes this issue:
<InstallExecuteSequence>
<Custom Action="ServerName.Set" Before="AdjustConfigurationFile">NOT Installed</Custom>
<Custom Action="AdjustConfigurationFile" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="CreateDatabase" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
The takeaway here is that if you're uninstalling the bootstrapper and the installer UI shows up again, THE MSI THREW AN ERROR and you should double check that logic.
Add to your MsiPackage element InstallCondition attribute with NOT Installed. If you want run install on upgrade then ypu have to add or UPGRADINGPRODUCTCODE.

Having trouble modifying a Built-in WixUI dialog set

I am trying to remove the license agreement from the built-in WixUI_InstallDir dialog set. I found some helpful instruction here
I've added this to the Product.wxs
<UI Id="InstallDir">
<UIRef Id="WixUI_InstallDir" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">NOT Installed</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
</UI>
The next button on the welcome dialog happily goes to the install directory dialog, but the back button of InstallDirDlg goes to the license agreement.
Any ideas would be appreciated.
I posted this question in the WiX-user mailing list. The consensus was that trying to change some of the publish commands in a built-in dialog set is not a "recipe for success". Instead I got the source wxs for the WixUI_InstallDir, made a copy of it (WixUI_NOEULAInstallDir), modified it and included in my project. I was trying to avoid having a custom dialog file in all my solutions, but I was able to export a project template that has the custom dialog included, so it's not so bad.

Prompt to uninstall older version of APP in WiX

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>

Wix: show custom dialog if previous version found

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