WiX burn bootstrapping run different InstallCommand parameter for silent install - wix

I have a Wix installer which needs to use a bootstrapper. I have included an extract of the Bundle.wxs below. It shows the Chain, which is to first install .Net 4.5.2 and then depending upon whether the installer has been called with -s for silent install calls ExePackage with or without the InstallCommand with a value of /S. The "OtherInstaller" is a NSIS (nulscript installer) installer so requires a case sensitive /S to trigger it's silent install. I understand that UILevel=2 is the condition to check for for a silent install, but for some reason "OtherInstaller" is not getting called with the /S silent argument. Then after that the "MainMsiInstaller" is called.
<Chain>
<PackageGroupRef Id="NetFx452Web"/>
<ExePackage Id="OtherInstallerLoud"
SourceFile="..\..\bootstrapper\OtherInstallerFile"
InstallCondition="NOT UILevel=2"/>
<ExePackage Id="OtherInstallerSilent"
SourceFile="..\..\bootstrapper\\OtherInstallerFile"
InstallCommand="/S "
InstallCondition="UILevel=2"/>
<MsiPackage Id="MainMsiInstaller"
DisplayInternalUI="yes"
SourceFile="..\..\bin\$(var.CandleCfgName)\MainMsiInstaller.msi" />
</Chain>
Any help appreciated.

In the end a solution that worked for me (whether the best solution, or not) was to ensure that the version of burn.exe I was using was 3.11.xxxx and InstallCondition="WixBundleUILevel=2" which is a WIX variable which is available in v3.11 upwards.
So in essence...
<Chain>
<PackageGroupRef Id="NetFx452Web"/>
<ExePackage Id="OtherInstallerLoud"
SourceFile="..\..\bootstrapper\OtherInstallerFile"
InstallCondition="NOT WixBundleUILevel=2"/>
<ExePackage Id="OtherInstallerSilent"
SourceFile="..\..\bootstrapper\OtherInstallerFile"
InstallCommand="/S "
InstallCondition="WixBundleUILevel=2"/>
<MsiPackage Id="MainMsiInstaller"
DisplayInternalUI="no"
SourceFile="..\..\bin\$(var.CandleCfgName)\MainMsiInstaller.msi" />
</Chain>

Related

How to conditionally install third party applications in WiX Bundle

I have a WiX installer and I have created a bootstrapper project for the same in order to install my pre requisites. However, I would like pre-requisites to only get installed if they are not already there on the system. Is it possible to add such a condition to my code?
This is the code I have right now, where in it installs my application. But I would like to add the conditions to it.
<Fragment>
<PackageGroup Id="OpenTAP">
<ExePackage
SourceFile="..\..\..\External\Prerequisites\OpenTAP\ITS_OpenTap.9.18.5_Installer.exe"
DetectCondition="ExeDetectedVariable"
InstallCommand="/q /ACTION=Install"
RepairCommand="/q ACTION=Repair /hideconsole"
UninstallCommand="/q ACTION=Uninstall /hideconsole" />
</PackageGroup>
</Fragment>
The ExePackage will only install if the DetectCondition is false. So, as long as you are setting the ExeDetectedVariable correctly then Burn will behave exactly as you desire.

Permissions problem with Wix Custom Action and Burn bootstrapper

I have a package that needs to be installed with elevated administrator privileges. However, this installer includes an uninstall custom action to run a clean-up executable, which must be run as the local user.
This all works fine for the generated MSI (install and uninstall), but when I wrap the MSI up in a Burn bootstrapper, the uninstall custom action is instead run as the administrator - and hence fails...
My application must be installed “perMachine”, and so in my Product.wxs I have my package setup with
InstallPrivileges="elevated"
InstallScope="perMachine"
However, this application's uninstaller includes an uninstall custom action to run a clean-up executable, which must be run as the local user (since it looks for a file in the user’s App-Data). So I’ve set the CustomAction to
Impersonate="yes" Execute="immediate"
And have:
<InstallExecuteSequence>
<Custom Action="UninstallCleanup" Before="RemoveFiles">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
This builds my MSI file, which I can then install on my machine. When I then run the uninstall, either via the Control Panel or manually (msiexec /x MyInstaller.msi /l* Testing.log), I am prompted for an admin password, the application is uninstalled, and the custom action is run as the local user. Everything perfect.
BUT I need to wrap this MSI up in a WiX Burn bootstrapper EXE that also installs pre-requisites (the VC runtime) before running my MSI package. Now when this Package Bundle is installed, and then uninstalled via the control panel, my MSI uninstall custom action is run as the administrator rather than the local user - and so fails.
In my Bundle.wxs file I have:
<PackageGroup Id="PP_Package">
<MsiPackage
Compressed="yes"
EnableFeatureSelection="no"
SourceFile="$(var.PP_MSI_PATH)"
Permanent="no"
DisplayInternalUI="no"
Visible="no"
Vital="yes">
<MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />
</MsiPackage>
</PackageGroup>
And
<PackageGroup Id="VCRedist">
<ExePackage Id="vcRedist_x86"
Cache="yes"
Compressed="yes"
PerMachine="yes"
Permanent="yes"
Vital="yes"
SourceFile="$(var.VCREDIST_X86_LOC)\$(var.VCREDIST_X86_FILE)"
Name="Redist\$(var.VCREDIST_X86_FILE)"
InstallCommand="/install /quiet /norestart"
Protocol="burn">
<ExitCode Value="1638" Behavior="success" />
<ExitCode Value ="3010" Behavior="forceReboot" />
</ExePackage>
</PackageGroup>
And then:
<Chain>
<PackageGroupRef Id="VCRedist" />
<RollbackBoundary Vital="yes" />
<PackageGroupRef Id="PP_Package" />
</Chain>
What have I got wrong? Is the issue something like: WiX Burn detects that the MSI is perMachine and so starts it using elevated admin, so that the custom action interprets Impersonate="yes" as meaning the administrator rather than the local user?
Any help, explanations and solutions would be most welcome.

Wix bootstrapper webinstaller does not download msi-file

In my bootstrapper I want to install one package as a webinstallation. Therefore I added the following MsiPackage to the Bundle´s Chain
<MsiPackage DisplayInternalUI="yes" Visible="yes" Id="NodeJs"
Compressed="no"
ForcePerMachine="yes"
SourceFile="node-v0.10.32-x86.msi"
DownloadUrl="https://nodejs.org/dist/v0.10.32/node-v0.10.32-x86.msi">
<MsiProperty Name="INSTALLFOLDER" Value="[Global_InstallFolder]\NodeJs" />
However, the installation only works as expected when the to-download-msi-file is in the same directory as the bootstrapper-exe.
In other words, it does not download the msi-file.
What am I doing wrong?

Wix Toolset prerequisites: Check for .Net Framework

I have a wix bundle project that I am editing (ver 3.10). I am trying to use the wixnetfxextensions to install .net framework 4.6 if it is not already installed. I created an exepackage that uses the WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED property. I'm guessing I am not using this correctly. Any help on how to use that? Currently the .net framework will not install not matter what.
<Chain>
<PackageGroupRef Id="redist_vc140" />
<PackageGroupRef Id="NetFx461Full" />
<MsiPackage Id="MSI_Installer" SourceFile="C:\Installer.msi"/>
</Chain>
<Fragment>
<PropertyRef Id="WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED"/>
<!-- Install .NET 4.6.1 -->
<PackageGroup Id="NetFx461Full">
<ExePackage Id="NetFx461"
DisplayName="Microsoft .NET Framework 4.6.1"
Compressed="no"
Cache="yes"
PerMachine="yes"
Permanent="yes"
Protocol="netfx4"
Vital="yes"
SourceFile="..\NDP461-KB3102436-x86-x64-AllOS-ENU.exe"
UninstallCommand="/q /norestart"
RepairCommand="/q /norestart"
DetectCondition="NOT WIX_IS_NETFRAMEWORK_46_OR_LATER_INSTALLED" />
</PackageGroup>
</Fragment>
You're doing a lot of extra work to install .net that you don't actually need to do.
To add .net 461 to your installer just include the netfxextension and add
<Bundle>
<PayloadGroup Id="NetFx461RedistPayload">
<Payload Name="redist\NDP461-KB3102436-x86-x64-AllOS-ENU.exe"
SourceFile="C:\path\to\redists\in\repo\NDP461-KB3102436-x86-x64-AllOS-ENU.exe"/>
<PayloadGroup/>
</Bundle>
so that the full installer is included in your bootstrapper. You can ignore this and then the bootstrapper will download the installer but if the customer doesn't have an internet connection they won't be able to install .net.
Then in your chain just add
<PackageGroupRef Id="NetFx461Redist"/>
I used this as a reference and checked the wix source to see what the
name of .net 461 being used is in netfxextension.
Sean Hall mentioned that bundles don't even use properties so what I had written here doesn't apply at all in this situation. (And it was also incorrect)
Did what Brian Sutherland suggested: Added the WxsVariable that compares the .netframework with the determined minimum release number. then make that a detectcondition in the exepackage

WiX - Does Burn support dual-purpose msi packages?

Does Burn support dual-purpose (per-user or per-machine) MSI packages which were prepared according to these Microsoft guidelines?
I tried to prepare such a package, but it looks like bootstrapper created with Burn doesn't uninstall MSI package, which was installed per-machine after raising UAC privileges by End-User.
The source code for Burn is:
<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 Version="1.0"
Name="AppNameHere"
UpgradeCode="GuidHere">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense" >
<bal:WixStandardBootstrapperApplication LicenseUrl=""
SuppressOptionsUI="yes"
ThemeFile="Customization\Theme.xml"
LocalizationFile="Customization\LangHere.wxl"/>
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef Id="WindowsInstaller45"/>
<PackageGroupRef Id="NetFx40ClientRedist"/> <!-- Uzywa rozszerzenia WixNetfxExtension do zainstalowania .net -->
<PackageGroupRef Id="vcredist"/>
<MsiPackage Compressed="yes"
SourceFile="MsiFileNameHere"
DisplayInternalUI="yes">
<MsiProperty Name="UPDATEDIR" Value="[UninstallPath]"/>
<MsiProperty Name="WIXBUNDLEKEY" Value="[WixBundleProviderKey]"/>
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" Value="Installed" Variable="vcredistkeyx86" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" Value="Installed" Variable="vcredistkeyx64" />
<PackageGroup Id="vcredist">
<ExePackage Id="vcredist_x86"
Cache="no"
Compressed="yes"
PerMachine="yes"
Permanent="yes"
Vital="yes"
SourceFile="Components\vcredist_x86.exe"
DetectCondition="(vcredistkeyx86 AND (vcredistkeyx86 >= 1)) OR (vcredistkeyx64 AND (vcredistkeyx64 >= 1))" />
</PackageGroup>
<PackageGroup Id="WindowsInstaller45">
<ExePackage Cache="no"
Compressed="yes"
PerMachine="yes"
Permanent="yes"
Vital="yes"
SourceFile="Components\WindowsXP-KB942288-v3-x86.exe"
InstallCondition="VersionNT=v5.1 AND NOT VersionNT64 AND VersionMsi < v4.5"
InstallCommand="/quiet /norestart">
<ExitCode Behavior="forceReboot"/>
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
As of WIX V3.9 the answer is a qualified "No" - Burn doesn't currently support dual-purpose per-user or per-machine MSI package.
A dual-purpose MSI package has the ALLUSERS property set to "2". When you build a WIX bootstrapper project referencing this type of MSI package you should see this type of warning:
2>D:\Robert\Documents\Visual Studio 2013\Projects\BurnTest\Bootstrapper\Bundle.wxs(18,0): warning LGHT1133: Bundles require a package to be either per-machine or per-user. The MSI 'D:\Robert\Documents\Visual Studio 2013\Projects\BurnTest\SetupProject\bin\Release\SetupProject.msi' ALLUSERS Property is set to '2' which may change from per-user to per-machine at install time. The Bundle will assume the package is per-machine and will not work correctly if that changes. If possible, remove the Property with Id='ALLUSERS' and use Package/#InstallScope attribute instead.
The build process for a WIX bootstrapper project will try and work out from the chained packages what type of burn installation to create (per-user or per-machine). The logic is convoluted because of the different places you can declare a preference for per-user or per-machine, and the potential conflicts between chained packages. But the general idea is the burn compiler will generate a per-machine installation, unless one of the chained packages is per-user, which will flip the burn installation into per-user mode. The key point is the decision to create a per-user or per-machine package is made at build time. To properly support dual-purpose MSI packages that decision would need to be moved to install time.