Updating WIX transformations - wix

I'm trying to create an installer (using WIX 3.11) which can install more instance's of the same program. I have managed to create an installer which does that, but the installer does not work when trying to do an update of the different instances
Here's my code
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Name="ABC Default" Manufacturer="Inc" Language="1033" Version="1.0.1.7"
Id="*"
UpgradeCode="{3984A5B2-5CDA-4EC8-933A-089E46E2D688}">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
Keywords="Installer" Description="Installer"
Comments="Instance installer" Manufacturer="Me"
Platform="x64"/>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UI>
<UIRef Id="WixUI_InstallDir" />
<!--Skip license dialog-->
<Publish Dialog="WelcomeDlg"
Control="Next"
Event="NewDialog"
Value="InstallDirDlg"
Order="2">1</Publish>
<Publish Dialog="InstallDirDlg"
Control="Back"
Event="NewDialog"
Value="WelcomeDlg"
Order="2">1</Publish>
</UI>
<MajorUpgrade AllowSameVersionUpgrades="yes" Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed" />
<MediaTemplate />
<Property Id="INSTANCEID" Value="0" />
<InstanceTransforms Property="INSTANCEID" >
<Instance Id="DEV" ProductCode="*" UpgradeCode="{BB75B4BE-6217-4FDA-8BAC-C46B402AC0FB}" ProductName="ABC Dev" />
<Instance Id="TEST" ProductCode="*" UpgradeCode="{ACFEFC2F-0D48-4640-9BBC-6E1162F9D1E7}" ProductName="ABC Test" />
</InstanceTransforms>
<Feature Id="ProductFeature" Title="Products" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<CustomAction Id="SetInstanceDirectory"
Property="InstanceDirectory"
Value="[INSTALLFOLDER][INSTANCEID]\"/>
<InstallExecuteSequence>
<Custom Action="SetInstanceDirectory"
Before="CostFinalize"><![CDATA[InstanceDirectory = ""]]></Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Inc" >
<Directory Id ="InstanceDirectory" Name="Instance"/>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="InstanceDirectory">
<Component Id="NotepadComponent" Guid="{52BCDD67-47F3-4F04-A7F9-6CAB42010CDE}" MultiInstance="yes">
<File Source="c:\Windows\System32\notepad.exe"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
As can be seen the installer is quite simple, but I need some help on the updating part.
Install procedure:
msiexec /i test_installer.msi
msiexec /i test_installer.msi MSINEWINSTANCE=1 TRANSFORMS=":DEV"
/l*vx log.log
msiexec /i test_installer.msi MSINEWINSTANCE=1 TRANSFORMS=":TEST"
/l*vx log.log
Update procedure:
msiexec /i test_installer.msi
msiexec /i test_installer.msi TRANSFORMS=":DEV" /l*vx log.log
When trying to update the DEV instance, the installer tries to update the default installation informing the user that the installation is up-to-date and repair or uninstall are possible.
Please help. I have been looking at this problem for more than a week now.
/Kenneth

MSINEWINSTANCE=1 should be specified always, because your updates are provided as major upgrade.
I just had a look at some code that uses instance transforms. There is no distinction between first install and upgrade install, the command-line is always the same.
This makes sense as a major upgrade is like a new product installation, the only difference being that it automatically removes the older version.

Related

Windows Installer XML(WIX) Help: Not able to execute shell command through exeCommand

Following is my code. I need to install the .inf and .cer files after execution of the MSI file. I have tried referring to various wix resources but couldn't find anything. I am testing the installer on a virtual machine but it doesn't seem to work. I am new to wix and need help regarding this by going through the code and pointing out my mistakes.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Cal" Language="1033" Version="1.0.0.0" Manufacturer="Cal" UpgradeCode="my-code">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="Cal" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<!--<CustomActionRef Id="InstallAction1" />-->
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Cal" />
<Directory Id="SilInst" Name="BackInst">
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="P2">
<File Source="C1.sys" />
</Component>
<Component Id="P6">
<File Source="C1.inf" />
</Component>
<Component Id="P7">
<File Source="C1.cer" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<CustomAction Id='InstallAction1' Directory='INSTALLFOLDER' ExeCommand='RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 C1.inf' Execute='deferred'
Return='check'/>
<CustomAction Id='InstallAction2' Directory='INSTALLFOLDER' ExeCommand='certutil -addstore C1.cer -s -r localMachine trustedpublisher' Execute='deferred'
Return='check'/>
<InstallExecuteSequence>
<Custom Action="InstallAction2" After='InstallFiles'/>
<Custom Action="InstallAction1" After='InstallAction2'/>
</InstallExecuteSequence>
</Fragment>
</Wix>
To troubleshoot, create an installation log, then search for the custom action id.
Installing driver and certificate on machine typically requires elevated permissions. Therefore use Impersonate="no" for your custom actions. See How to run a Custom Action inside an MSI created in WiX with elevated privileges?

Wix Installer to upgrade and remove files + registry entries

I have an application that needs 1. to create DLL files in a Program Files subfolder (e.g. C:\Program Files (x86)\myapp), and 2. to create a registry entry in HKCU. When I run the Remove, I need this subfolder and its files to be deleted, as well as the registry entry.
When I run the installation file of a newer version, I need the new DLL files to replace the existing ones.
I've been struggling getting it to work, having tried several tips from various threads and sites.
So far I get the Program Files to be removed but not the Registry. And I cannot get the file upgrade to work (I change the UpgradeCode & ProductVersion for each new release)
Here is an extract of what I have
<Product Id="$(var.ProductID)"
Name="myapp"
Language="1033"
Version="$(var.ProductVersion)"
UpgradeCode="$(var.UpgradeCode)"
Manufacturer="$(var.Manufacturer)">
<Package Description="Windows installer for myApp $(var.ProductVersion)"
Comments="Execute to install myApp $(var.ProductVersion)"
InstallerVersion="200"
Compressed="yes" />
<Media Id="1" Cabinet="contents.cab" EmbedCab="yes" CompressionLevel="high"/>
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)"
OnlyDetect="yes"
Property="NEWERVERSIONDETECTED" />
<UpgradeVersion Minimum="1.0.0.0"
IncludeMinimum="yes"
Maximum="$(var.ProductVersion)"
IncludeMaximum="no"
Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>
<CustomAction Id="UIandAdvertised" Error="Something about the UI."/>
<Directory Id="TARGETDIR" Name="SourceDir"/>
<Feature Id="Complete"
Title="myApp"
Description="Installation of myApp $(var.ProductVersion)"
Level="1">
<ComponentRef Id="myAppFiles"/>
<ComponentRef Id="RegistryEntry"/>
</Feature>
<Property Id="WIXUI_INSTALLDIR">INSTALLDIR</Property>
<UIRef Id="WixUI_InstallDir"/>
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<RemoveRegistryValues />
</InstallExecuteSequence>
</Product>
My files and reg infos are maintained in a separate file:
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="INSTALLDIR" Name="myapp">
<Component Id="myAppFiles" Guid="{xxxx-xxxx-xxxx-xxxx-xxxxxxxx}">
<File Id="myapp.dll" Name="myapp.dll" KeyPath="yes" Source="..\src\bin\x86\Release\myapp.dll" />
</Component>
<Component Id="RegistryEntry" Guid="{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx}" Win64="no" >
<RegistryKey Root="HKCU" Key="Software\myapp" Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Value="myapp" />
</RegistryKey>
</Component>
</Directory>
</Directory>
</DirectoryRef>
Any help will be highly appreciated.
Use Product ID ="*",
It changes product id guid for each build.
But keep upgrade code same for product, unless you dont want to support upgrade.
You can use major upgrade tag instead of Upgrade tag. It is easier to use.
<MajorUpgrade AllowDowngrades="no"
AllowSameVersionUpgrades="no"
Schedule="afterInstallValidate"
DowngradeErrorMessage="Newer version of [ProductName] is already installed."/>

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 how to hide feature options (no subfeatures)

There is a similar question
Edit context menu (selectiontree) in customize dialog?
but the link in the accepted answer states:
"You cannot remove Entire feature will be installed on local hard drive from the options. It is displayed only when there are subfeatures and enables installation of the subfeatures as well as the feature itself as opposed from Will be installed on local hard drive which installs only the selected features and does not affect subfeatures."
However, I have no subfeatures. How to remove the Entire feature... option?
Here's the code below:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WixTestFeatureTree" Language="1033" Version="1.0.0.0" Manufacturer="TestManufacturer" UpgradeCode="bb04a635-6251-4fd5-8d2f-182d3441dc0a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<Feature Id="ExeFeature" Title="The EXE file" Level="1">
<Component Id="TheApp" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestExe" Source="Test.exe" Vital="yes"></File>
</Component>
</Feature>
<Feature Id="PdfFeature" Title="The PDF file" Level="1">
<Component Id="ThePDF" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestPDF" Source="Test.pdf" Vital="yes"></File>
</Component>
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="WixTestFeatureTree" />
</Directory>
</Directory>
</Fragment>
</Wix>
It looks Windows Installer always displays Entire feature will be installed on local hard drive item even if there are no subfeatures. At least this item was present in all the cases that I tested where there were no visible subfeatures. It could also depend on the version of Windows Installer, I tested in Windows 7 with all the latest updates.
I've always thought Windows Installer doesn't display Entire feature will be installed on local hard drive item for a feature which has no subfeatures. Latest tests proved I was wrong.
You need to add the UI type in order to have a different UI in the installer.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WixTestFeatureTree" Language="1033" Version="1.0.0.0" Manufacturer="TestManufacturer" UpgradeCode="bb04a635-6251-4fd5-8d2f-182d3441dc0a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<UI Id="MyWixUI_FeatureTree">
<UIRef Id="WixUI_FeatureTree" />
</UI>
<UIRef Id="WixUI_ErrorProgressText" />
<Feature Id="ExeFeature" Title="The EXE file" Level="1">
<Component Id="TheApp" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestExe" Source="Test.exe" Vital="yes"></File>
</Component>
</Feature>
<Feature Id="PdfFeature" Title="The PDF file" Level="1">
<Component Id="ThePDF" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestPDF" Source="Test.pdf" Vital="yes"></File>
</Component>
</Feature>
<UIRef Id="WixUI_Mondo"></UIRef>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="WixTestFeatureTree" />
</Directory>
</Directory>
</Fragment>
</Wix>
add <UIRef Id="WixUI_Mondo"></UIRef> , also add reference to WixUIExtension.dll
each feature has **Level**attribute, level=1 meaning the feature will be installed, if you change the level for 1000 for example the user can pick in the custom dialog weather he wants to install this feature or not

Values of multiple PathEdit controls to multiple properties

I want to build an Installer with Microsoft Wix 3.8 that actually just registers some COM-components and creates some shortcuts to a program on a server share. Just to point that out in advance: This program is a legacy tool and the way it's launched or used won't be changed, unfortunately.
So I need my installer to ask for three paths: The server installation path (as unc), and two additional paths, also on the server (also as unc).
I'm already struggling with the first path. As soon as I add it it seems to be hard wired to some directory I have to specify in my product.wxs.
That's how my product.wxs looks like:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="613A5421-BF59-46DD-B363-05E55587B89F" Name="Test Client" Language="1033" Version="1.0.0" Manufacturer="Blub AG" UpgradeCode="A451E5EB-4AED-4A8A-ACBC-F65A34E86D45">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate />
<WixVariable Id="WixUIDialogBmp" Value="images\background.bmp" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<Feature Id='Complete' Title='Foobar 1.0' Description='The complete package.'>
<Feature Id='TestClient' Title='Test Client' Description='Test Client' Level='1'>
<ComponentGroupRef Id='ProductComponents' />
</Feature>
</Feature>
</Product>
<Fragment>
<PropertyRef Id="NETFRAMEWORK20"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="ExpoWin" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER" >
<Component Id="ProductComponent">
<File Source="Blub.txt" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
(In my original code I replaced the WixUI_InstallDir with my own version so that I can modify it to ask for three paths. But to point out my problem the code above should suffice)
I don't want the "INSTALLFOLDER" to be linked to any Directory. But as soon as I change
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
to
<Property Id="WIXUI_INSTALLDIR" Value="SERVERPATH" />
<Property Id="INSTALLFOLDER" Value="c:\program files (x86)\TestClient" />
and run the installer I get a "2343 error":
DEBUG: Error 2343: Specified path is empty.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2343. The arguments are: , ,
Well hopefully this question is easy to answer. I've been searching the web for hours. Probably I haven't understood the concept of properties entirely. Can someone shed some light on this?
The following explanation might not be valid 100%, it's the way that I explain it to myself ;-).
WiX takes the value of a property and uses it to resolve the path. In the first case it finds the property in the directory structure, so the path can be resolved. In the second example SERVERPATH is just the string SERVERPATH, so it can't find anything. You have to either set it using a registry search or to a concrete path or by a custom action.
What worked great for me in the UI and custom dialogs (I had a similar requirement with the installation folder and an additional path) was the answer to a similar question.
Here is an example for setting it via a custom action (INSTALLLOCATION in my case was read from the registry, but it can be any path; INSTALLDIR is defined by the directory structure in the WiX source file):
<CustomAction Id="SetINSTALLDIR" Property="INSTALLDIR" Value="[INSTALLLOCATION]" Execute="firstSequence" />
<InstallExecuteSequence>
<Custom Action="SetINSTALLDIR" After="AppSearch">INSTALLLOCATION</Custom>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="SetINSTALLDIR" After="AppSearch">INSTALLLOCATION</Custom>
</InstallUISequence>
Using the method described in the answer above I have the following in my WiX source file:
<Directory Id="LUCENEFOLDER" SourceName="LuceneIndex" />
The path is then set in the UI on a custom dialog by the following snippet:
<Control Id="LuceneFolderLabel" Type="Text" X="5" Y="155" Width="200" Height="10" Text="Folder containing Multiindex.config of Lucene:" TabSkip="yes" />
<Control Type="PathEdit" Id="LuceneFolder" Width="200" Height="17" X="5" Y="165" Property="LUCENEFOLDER"/>
<Control Id="LuceneFolderBrwsButton" Type="PushButton" Width="56" Height="17" X="210" Y="164" Text="Change..." >
<Publish Property="_BrowseProperty" Value="LUCENEFOLDER" Order="1">1</Publish>
<Publish Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
</Control>