Update MSI package via Wix bootstrapper - wix

I have wix bootstapper which includes 4 components: tree exe packages and one msi package. I want to do major update of msi package using bootstrapper below (only main code):
<Bundle Name="$(var.Name)" Version="$(var.Version)" Manufacturer="$(var.Manufacture)" UpgradeCode="$(var.UpgradCode)" Copyright="$(var.Copyright)">
....
<Chain>
<!-- TODO: Define the list of chained packages. -->
<PackageGroupRef Id="NetFx4Full"/>
<PackageGroupRef Id="PostgreSQL"/>
<PackageGroupRef Id="AdobeReader"/>
<PackageGroupRef Id="Application"/>
</Chain>
....
<PackageGroup Id="Application">
<MsiPackage Id="MyApplication"
SourceFile=".\MSI_File\application.msi"
DisplayInternalUI="yes"
Permanent="no"
Vital="yes"
Visible="no"/>
others packages...
</PackageGroup>
and msi code:
<Product Id="*"
Name="$(var.Name)"
Language="$(var.InstallerLanguage)"
Version="$(var.Version)"
UpgradeCode="$(var.UpgradeCode)"
Manufacturer="$(var.Manufacture)">
<Package Description="$(var.PackageDescritpion)"
InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated"
Platform="x64"/>
<Media Id="1" Cabinet="contents.cab" EmbedCab="yes" CompressionLevel="high"/>
<Directory Id="TARGETDIR" Name="SourceDir">
</Directory>
<Feature Id="Complete"
Level="1"
ConfigurableDirectory="INSTALLDIR">
<ComponentRef Id="Licence"/>
<ComponentRef Id="StartMenuFoldersComponent"/>
<ComponentRef Id="DatabaseConfigFolder"/>
<ComponentGroupRef Id="BinaryFileGroup"/>
<ComponentGroupRef Id="DatabaseConfigFileGroup"/>
<ComponentRef Id="ApplicationConfigFolder"/>
<ComponentRef Id="RemoveFolderOnUninstall"/>
</Feature>
<!-- Custom actions-->
.....
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
<!--Other custom actions-->
......
</InstallExecuteSequence>
To build my update msi and bootstrapp I set greater (the same for msi and bootstrapp) product version, for example old version has 1.0.0.0 and newer has 1.0.1.0. Upgrade code as a WIX documentation says remains unchanged. After run my update installer the new version of msi is not installig, in install directory still are old files. Does anyone know what I do wrong?
#Edit
Also I tried by adding MajorUpgrade element but after that bootstrapper doesn't start MSI:
<Media Id="1" Cabinet="contents.cab" EmbedCab="yes" CompressionLevel="high"/>
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."/>
<Directory Id="TARGETDIR" Name="SourceDir"/>
#Edit
Bootstrapper logs: http://wklej.to/Msczq

You need to add upgrade information to the .msi package. See http://wixtoolset.org/documentation/manual/v3/howtos/updates/major_upgrade.html for use of the MajorUpgrade element.

Related

WIX CustomAction conditions

I created a simple WIX project with a "Hello world" custom action and checked how it works. I intended the custom action to be executed only on the first install, but it executed on every major update(where both the product code and its version change). I found in the log that the custom action condition is checked after uninstall - when the Installed variable is false again.
How do I execute a custom action on the first install only and not on major updates, using the WIX toolset?
Is there a way without manual use of the registry?
<Product Id="52D5F5ED0C3F453CA70E280ECD7D7400"
Name="TestWiXSetup"
Language="1033"
Version="1.0.2.0"
Manufacturer="Some RnD"
UpgradeCode="12777105-8bc1-47b5-8b36-2705ef02cb79">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab='yes' />
<Feature Id="ProductFeature" Title="TestWiXSetup" Level="1">
<ComponentRef Id="Component" />
</Feature>
<Binary Id="HW" SourceFile="HW.exe" />
<CustomAction Id="HWA" BinaryKey="HW" ExeCommand="" Execute='deferred'/>
<InstallExecuteSequence>
<Custom Action='HWA' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="TestWiXSetup">
<Component Id="Component">
<File Source="ToDeploy.txt"/>
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>

How to make certain a Wix installer will override (upgrade) an older version and won't allow a downgrade

I've tried most of the answers on the topic in this forum and other forums, but I still have this problem.
I want to update a bundle version and when I build and install the installer, it should upgrade a previous installation and not create two records in "Programs and Files".
I'm using the following code in Product.wxs.
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="miro" UpgradeCode="5ba49b49-25c4-47c0-82da-12bf5310af58">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="yes" IgnoreRemoveFailure="no" DowngradeErrorMessage="loc.NewerVersionInstalled" Schedule="afterInstallInitialize"/>
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent">
<File Id="file_Exefile" Source="..\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe">
</File>
</Component>
</ComponentGroup>
</Fragment>
I am even considering writing my own update logic based on the Installer Processes and their ProductVersion properties, but there are too many cases to consider.
Can you tell me what is wrong with this Product.wxs ,so I can fix it.
Thanks.
Best regards,
Evgeni Dyulgerov
There are several things that could be preventing a major upgrade. You appear to have the correct MajorUpgrade logic, but:
It would be better if you incremented your product version in the first three fields, that's more normal for a major upgrade.
It's not obvious that your current UpgradeCode is the same as the older product's, so check that it is.
If the previous product's install scope was perUser the major upgrade will not work because cross-context major upgrades aren't allowed by Windows Installer.
Do the install taking a verbose log and look at all occurrences of FindRelatedProducts. There will be more than one, but see if the one in the upgrade install finds a previously installed product.
You have to add an upgrade section to your product section.
<Upgrade Id='5ba49b49-25c4-47c0-82da-12bf5310af58'>
<UpgradeVersion OnlyDetect='no' Property='ISUPGRADE'
Minimum='0.0' IncludeMinimum='yes'
Maximum='1.0.0.0' IncludeMaximum='no' />
</Upgrade>
Checkout Upgrades and Modularization on Firegiant
Also the WiX Documentation chm (in your Start Menu) is very helpful.

wix 3.8 silent install - ui level 2

I want to create a WIX Installer (3.8) that only installs silently.
I'm using the Wix file attached to demonstrate my issue.
At
UILevel=2
<InstallExecuteSequence>
<FindRelatedProducts Before="LaunchConditions">UILevel=2</FindRelatedProducts>
</InstallExecuteSequence>
I'm setting the UI level to 2
According to:
msdn.microsoft.com/en-us/library/aa372096%28v=vs.85%29.aspx
then it's:
"
INSTALLUILEVEL_NONE 2 Completely silent installation.
"
So far so good. I can install the "product" which is nothing but an empty directory.
When I set the product's version to: Version="1.1.0.0" and want to do a major upgrade everything also works fine.
When I look at the program an feature "tool" from Microsoft
as shown here:
http://windows.microsoft.com/en-us/windows/uninstall-change-program#uninstall-change-program=windows-7
I see both versions (version 1.0.0.0 and 1.1.0.0) which is not what I expected the Wix installer should do.
When I remove
<InstallUISequence>
<FindRelatedProducts Before="LaunchConditions">UILevel=2</FindRelatedProducts>
</InstallUISequence>
<InstallExecuteSequence>
<FindRelatedProducts Before="LaunchConditions">UILevel=2</FindRelatedProducts>
</InstallExecuteSequence>
from the Wix script, install Version 1.0.0.0 and later after changing the wix script to 1.1.0.0
and major upgrading again,
I only see 1 version (1.1.0.0) at the program an feature "tool" from Microsoft
( windows.microsoft.com/en-us/windows/uninstall-change-program#uninstall-change-program=windows-7 )
which is what I expect the windows installer should do.
So my question would be:
What is missing or wrong at the script
( that the program an feature "tool" from Microsoft shows 2 Versions after a major upgrade )
Wix script:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.1.0.0" Manufacturer="asdf" UpgradeCode="BE170BF6-0C06-4A50-B81B-CDF6609FAD5A">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" InstallPrivileges="limited" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallInitialize" />
<MediaTemplate />
<InstallUISequence>
<FindRelatedProducts Before="LaunchConditions">UILevel=2</FindRelatedProducts>
</InstallUISequence>
<InstallExecuteSequence>
<FindRelatedProducts Before="LaunchConditions">UILevel=2</FindRelatedProducts>
</InstallExecuteSequence>
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="LocalAppDataFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="test" Guid="D6527568-4C76-493B-AF1F-9E973723E773"
SharedDllRefCount="no" KeyPath="no" NeverOverwrite="no" Permanent="no" Transitive="no"
Win64="no" Location="either">
<CreateFolder/>
<RemoveFolder Id="ProductComponents" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\MyFantasyCompany\MyApplicationName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
First, there's no such thing as WiX script. WiX is not a imperative programming language, it's a declarative language.
Your major upgrade is failing because the condition on FindRelatedProducts is evaluating to false which means it can never detect the ProductCode of the previous MSI and remove it as part of the upgrade.
If you really want a silent install only, why not just omit a UI from the installer? Personally I have no idea why you are trying to do this and it doesn't follow established best practices.

WiX Bundle upgrade: a new version of MSI is installed before the old version is removed

I have a WiX bundle that installs an MSI and also checks if .NET is installed. Everything works as expected when installing the bundle (and the installer).
My problem is when the bundle is upgraded. In an upgrade, the bundle first installs v_Next of the MSI and when then unininstalls v_Previous of the MSI.
How can I change this order? I want that in an upgrade the v_Previous of the MSI is uninstalled before the v_Next is installed.
Below is my bundle:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="MyProductName"
Version="1.0.0.0"
Manufacturer="MyCompanyName"
UpgradeCode="4abf3f67-1234-35b1-b2c1-dd7649b60e1d">
<BootstrapperApplicationRef
Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
SuppressOptionsUI="yes"
LicenseFile="License.rtf"
ThemeFile="Theme.xml"
LogoFile="MyProductName.png"
/>
<Payload
Name="BootstrapperCore.config"
SourceFile="BootstrapperCore.config"/>
<Payload
SourceFile="NetfxLicense.rtf"/>
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef
Id="Netfx4Full"/>
<MsiPackage
Compressed="yes"
SourceFile="$(var.SolutionDir)\Setup\MyProductName.msi"
Vital="yes">
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<WixVariable
Id="WixMbaPrereqPackageId"
Value="Netfx4Full" />
<WixVariable
Id="WixMbaPrereqLicenseUrl"
Value="NetfxLicense.rtf" />
<util:RegistrySearch
Root="HKLM"
Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"
Value="Version"
Variable="Netfx4FullVersion" />
<util:RegistrySearch
Root="HKLM"
Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full"
Value="Version"
Variable="Netfx4x64FullVersion"
Win64="yes" />
<PackageGroup
Id="Netfx4Full">
<ExePackage
Id="Netfx4Full"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
Vital="yes"
SourceFile="$(var.SolutionDir)\packages\dotNetFx40_Full_x86_x64.exe"
DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193"
DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)"/>
</PackageGroup>
</Fragment>
</Wix>
Thank you Rob for the answer. I'm trying to do that, but it's not working (I'm surelly missing something)... This is what I have in the MSI:
<Product Id="*"
Name="MyProductName"
Language="1033"
Version="1.0.0.0"
Manufacturer="MyCompanyName"
UpgradeCode="aa027fd0-5111-1236-9af6-55581a588123">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of MyProductName is already installed."
AllowDowngrades="no"/>
<MediaTemplate />
<Feature Id="ProductFeature"
Title="MyProductName"
Level="1">
<ComponentRef Id="ApplicationShortcut" />
<ComponentGroupRef Id="AllFiles" />
</Feature>
</Product>
If I run the v_previous MSI and then v_Next MSI (separatelly, not within the bundle) I get both installed, so no upgrade is being performed. What Am I doing wrong?
Nevermind, MajorUpgrade is working. My version numbering was wrong in the vNext MSI. I need now to also add minor upgrade support.
Upgraded bundles are always uninstalled last today**. To remove v_Previous.msi before v_Next.msi, have the v_Next.msi major upgrade (see the MajorUpgrade element) the v_Previous.msi.
** I think there is a feature request to allow other placements but no one has implemented that yet.

setup doesn't uninstall files

I have a very simple setup project:
<Product Id="*" UpgradeCode="$(var.UpgradeCode)" Name="$(var.ProductLongName)" Language="1033"
Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<!-- Installation Parts -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WindowsFolder">
<Component Id="ProductComponent" Guid="b3250107-4859-4d5f-857c-1756af65ec32">
<File Id='SomeFile' Name='SomeFile.scr'
Source='SomeFile.scr' Vital='yes' />
<!-- Other files -->
</Component>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="$(var.ProductShortName)" Level="1">
<ComponentRef Id="ProductComponent" />
<!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->
<ComponentGroupRef Id="Product.Generated" />
</Feature>
<!-- Prerequisites -->
<PropertyRef Id="NETFRAMEWORK40CLIENT"/>
<Condition Message="This application requires .NET Framework 4.0. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK40CLIENT]]>
</Condition>
</Product>
It installs ok and uninstall seem to finish ok too, but all files remain. They are not deleted.
Any ideas?
So, this problem is gone when I changed component guid to a freshly generated. Don't really understand why. Weird.
The component GUID in the OP was all in lower case. By convention MSI prefers GUIDs to be all in upper case just in case you need to pass the GUID across the service boundary as a (public) property. Was your new GUID all in upper case, by any chance?