Uninstall shortcut in WiX when Product Id is * to allow major upgrades? - wix

I was following the tutorial here to implement an uninstall shortcut in the start menu.
In short, the way to create the uninstall entry is as follows:
<Shortcut Id="UninstallProduct"
Name="Uninstall My Application"
Target="[SystemFolder]msiexec.exe"
Arguments="/x [ProductCode]"
Description="Uninstalls My Application" />
Based on Rob Mensching's suggestion here, if the application is small enough and you don't need to handle small updates and minor upgrades (which I don't), you can force every update to be a major upgrade. This is shown here. I used Rob's suggestion which was this:
<Product Id="*" UpgradeCode="PUT-GUID-HERE" Version="$(var.ProductVersion)">
<Upgrade Id="PUT-GUID-HERE">
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.ProductVersion)" Property="NEWERVERSIONDETECTED" IncludeMinimum="no" />
<UpgradeVersion OnlyDetect="no" Maximum="$(var.ProductVersion)" Property="OLDERVERSIONBEINGUPGRADED" IncludeMaximum="no" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
Now my question is if Product Id is randomized (*) to allow a major upgrade to take place, is there any other way to add an uninstall shortcut to the start menu or must we do it through Add/Remove programs? I'd prefer to create the shortcut in the start menu since it's just easier for the user. Obviously the way it is now, it won't work because [ProductCode] that is used in the msiexec arguments will change on every install. Thanks.

Are you saying you've tried it and it doesn't work? How does it fail? What is the shortcut argument? Using Product/#Id="*" sets the ProductCode property, so it should work correctly.

Related

Wix Not showing Repair Option in UI

I implemented upgrade handlers and downgrade prevention
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion OnlyDetect="no" Minimum="$(var.MinimumUpgradeVersion)" Maximum="$(var.ProductVersion)" IncludeMinimum="yes" IncludeMaximum="no" Property="PREVIOUSVERSIONINSTALLED" MigrateFeatures="yes" />
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.ProductVersion)" IncludeMinimum="no" Property="NEWERVERSIONINSTALLED" />
</Upgrade>
And further on
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWERVERSIONINSTALLED AND NOT Installed</Custom>
<RemoveExistingProducts After="InstallInitialize">PREVIOUSVERSIONINSTALLED</RemoveExistingProducts>
However, now when I try to double-click my MSI to do a repair the UI doesn't appear anymore. I am using the same Upgrade Code so Wix should automatically allow me to repair.
Any ideas?
To do a major upgrade it might be better to use the majorupgrade element to make sure that you've included everything required. That's assuming you want a major upgrade, and I can't tell.
You are misunderstanding something. You (in WiX) use the majorupgrade element when you have a new version of your product that will replace the older one, and that includes a new ProductCode and the same UpgradeCode. This is nothing to do with repair. A repair is one of the options that can be available when you try to modify the existing installed product as defined by ProductCode, not UpgradeCode. A repair is not an upgrade or any kind of update. It repairs the existing product and will require the same MSI file that the product was originally installed from. The same UpgradeCode is nothing to do with repair.
What GUI are you including? See an online tutorial here: http://wix.tramontana.co.hu/tutorial/user-interface/ui-wizardry
Are you setting the ARPNOREPAIR property? Check in the registry at the following location (subkey, check for DWORD NoRepair):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

I have installed major upgrade successfully but it also allowing another previous version install in wix

I have installed major upgrade (say #206) successfully and included code as in (#206):
<Upgrade Id="$(var.ProductUpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="1033" Property="NEWPRODUCTFOUND" />
<UpgradeVersion Minimum="1.0.0.178" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Language="1033" Property="UPGRADEFOUND" />
</Upgrade>
Scenario is:
I have installed build #177 then upgraded to build #206. It is still allowed to install #177 which I want to prevent this downgrade.
From build #178 onward I have changed product GUID for major upgrade and which is working fine.
Please suggest how to prevent this. I don't want to downgrade build below 177. If I have done major upgrade on build no <= 177.
Your problem is the how the comparison of versions is done in MSI by default - 1.0.0.123 is treated the same as e.g. 1.0.0.33. You either have to increase your revision version to make the installer detect this as an older version or use a workaround.
You might for instance create a custom action to check against this very Revision version and place it e.g. before InstallValidate:
<CustomAction Id='MyVersionCheck' Return='check' (...) />
<InstallExecuteSequence>
<Custom Action='MyVersionCheck' Before='InstallValidate' />
</InstallExecuteSequence>
Some more information can be found in this article, for informations about how to create custom actions i'd recommend this blog entry as a starting point.

Majorupgrade or Upgrade ID which is preferred for Major upgrade?

We are trying to do Major upgrade. While i was investigating i found 2 approaches.
One is using Upgrade Id and another one approach was Majorupgrade tag.
It seems Majorupgrade is easy to do it seems. But schedule doesn't contain any before installinitialize action.
I am not sure which should be using .
Which one is preferred [and recommended] mostly?
The MajorUpgrade element was introduced in wix 3.5 to simplify what you would normally do with the Upgrade element. So that instead of something like this:
<!– Major upgrade –>
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />
<UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>
<Condition Message="Can't downgrade">
NOT NEWERVERSIONDETECTED
</Condition>
You can simply do this:
<MajorUpgrade DowngradeErrorMessage="Can’t downgrade." />
Not only is the old way more verbose, it also requires that you repeat the upgrade code and product version which are specified in the Product element. So the sample above has to make use of wix variables to keep them in sync. If you get that wrong, the upgrade won't work correctly.
The new MajorUpgrade element has none of those complications, so I recommend that you use it. See also this blog post by Bob Arnson introducing MajorUpgrade and the topic in the wix documentation on the subject.

WiX installer - problems updating

I'm having the worst time trying to configure WiX to NOT remove some configuration files from the installation directory during updates.
I've searched and googled but I'm stuck...
Here's what I have.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" ... >
<Product Id="PRODUCT_GUID" ...
UpgradeCode="UPGRADE_GUID">
...
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion OnlyDetect="no" Property="REMOVEOLDVERSION" Maximum="$(var.ProductVersion)" IncludeMaximum="no" />
<UpgradeVersion OnlyDetect="yes" Property="NEWERFOUND" Minimum="$(var.ProductVersion)" IncludeMinimum="no" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
...
And the files are as followed:
<Component Id="ConfigurationFiles" Guid="ConfigurationFiles_GUID" NeverOverwrite="yes">
<File Id="SomeConf" Source=... />
</Component>
What am I doing wrong?
If the problem is really the removal of the configuration files, then I think you meant to specify Permanent="yes" instead of NeverOverwrite="yes".
However, if the configuration files are not installed by the new version of the installer (which is why they disappear after the upgrade, I presume) then they shouldn't be necessary right? I'm not sure why you would want to keep the configuration files in that case. Marking them permanent effectively makes it impossible to uninstall them.
If you are actually worried about overwriting changes made to those configuration files by the user, then I think Windows Installer will already handle this correctly. The File Versioning Rules already have a concept of "user data" based on file modification timestamps, and will not overwrite such files.

How to move user content in Wix Installer

To support Window Vista in my game, I have changed were the save files are placed (From under Program Files to My Documents) for both XP and Vista installations.
Now I would like to be able to move the current XP users save games from the old location to the new location.
I think I can correctly trigger this via the upgrade checking code like so:
<Upgrade Id="PLACE-GUID-HERE">
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.ProductVersion)" IncludeMinimum="no" Property="NEWERVERSIONDETECTED" />
<UpgradeVersion OnlyDetect="no" Minimum="1.1.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" />
<UpgradeVersion OnlyDetect="no" Maximum="1.1.0" IncludeMaximum="no" Property="MOVESAVEFILESUPGRADED" />
</Upgrade>
where 1.0.x was the old way and 1.1.x will be the new way, thus I could do something in a custom action based on MOVESAVEFILESUPGRADED, but the heart of the problem, I cant see how to move non-installed files from one location to another.
Use the CopyFile element. A custom action is overkill and VBScript custom actions are unreliable. See http://www.joyofsetup.com/2007/06/07/when-vbscript-and-jscript-custom-actions-are-even-more-evil/.
I dont think there is a built in custom action that will do that.If you write your own its best to use a dll, but vbscript or bat file will also do the job.
This might help