WiX bootstrapper application - visual-studio-2012

I want a bootstrapper to install .NET 4.5 (if not available) before installing my setup.msi. If the machine has .NET 4.5 then I want to install the product setup.msi only.
Following is my code:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle Name="AAA" Version="1.0.0.0" UpgradeCode="8DA460D6-B4CB-4ED0-A1FE-44F269070647">
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef Id="Netfx45FullP"/>
<MsiPackage Compressed="yes" Vital="yes" Id="PMService" Cache="yes" Visible="no"
SourceFile="C:\Users\abc.msi">
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<WixVariable Id="WixMbaPrereqPackageId" Value="Netfx45Full" />
<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="Netfx45FullP">
<ExePackage Id="Netfx45" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
InstallCommand="/q"
SourceFile="dotNetFx45_Full_x86_x64.exe"
DetectCondition="(Netfx4FullVersion="4.5.50709") AND (NOT VersionNT64 OR (Netfx4x64FullVersion="4.5.50709"))"
InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion="4.5.50709" OR Netfx4x64FullVersion="4.5.50709"))"/>
</PackageGroup>
</Fragment>
</Wix>

You'll want to remove the AND (NOT (Netfx4FullVersion="4.5.50709" OR Netfx4x64FullVersion="4.5.50709") part of your install condition.
The detect condition will handle the case of telling if the .NET Framework is installed. If it is detected as installed, it will not be installed again.
The install condition will determine if the package should be allowed to be on the machine or not. If it evaluates to false the package will be uninstalled from the machine.
By adding the detect condition to the install condition your basically making it never true that the package can be installed on the machine and stay on the machine. :)

Related

Enabing IIS using CAQuietExec64 in Wix installer does not work

I need to make a windows installer which enables (installs) IIS on windows.
When I run the .msi file, it runs without any give any however, IIS does not get enabled(installed) when I go to Program and Features/Turn Windows Feature on off, it does not get installed
Here is my wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="IISInstaller" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="21ece05f-bf5c-4f97-850e-cb7cef2bf65e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Property Id="QtExec64CmdLine" Value='"[WindowsFolder]Sysnative\dism.exe" /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-WebServer
/FeatureName:IIS-WebServerRole /FeatureName:IIS-RequestFiltering /FeatureName:IIS-Security
/FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ASPNET /FeatureName:IIS-ISAPIExtensions
/FeatureName:IIS-ISAPIFilter /FeatureName:IIS-DefaultDocument /FeatureName:IIS-HttpErrors /FeatureName:IIS-StaticContent
/FeatureName:IIS-HttpLogging /FeatureName:IIS-RequestMonitor /FeatureName:IIS-HttpCompressionStatic
/FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-RequestFiltering /FeatureName:IIS-WindowsAuthentication'/>
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check" />
</Product>
</Wix>
even when I change the value in the property to run a simple command to make directory
mkdir test
it does not work either.
Could you please help me what is the problem?
Thanks
Two potential problems:
You have declared the custom action but you haven't put it in a sequence by declaring where it's going to run and what conditions apply. So it didn't run.
Step 2 is missing: http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html
After you've done that, the custom action is marked immediate which is usually an error because changes to the system should be done in deferred mode, and immediate custom actions don't run elevated.

WIX Installer error during the build

I try to learn how to do an installer with WIX on Visual Studio 2012, First I create an HelloWorld Project to test WIX and to do an easy configuration. But I have an error during the building : It says me :
"Failed to open the database. During validation, this most commonly happens when attempting to open a database using an unsupported code page or a file that is not a valid Windows Installer database. Please use a different code page in Module/#Codepage, Package/#SummaryCodepage, Product/#Codepage, or WixLocalization/#Codepage; or make sure you provide the path to a valid Windows Installer database. light.exe 0 1 SetupProject1"
I see several solution like change XML's encoding, switch utf-8 by utf-16. And I also try to delete the encoding statement. But it changes nothing.
Here is my WIX XML :
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="54612752-7163-4B36-8CA6-01615090CD7F" Name="WIXTestSetup" Language="1033" Codepage="1252" Version="1.0.0.0" Manufacturer="MyCompany Ltd."
UpgradeCode="1756bfd5-c713-412a-9524-fb1b72886116">
<Package Id="*" Keywords="Installer" Description="My WIXTest Installer" Languages="1033" SummaryCodepage="1252" InstallerVersion="200"
Compressed="yes" InstallScope="perMachine" Comments="WIXTest Installer is a registered trademark of MyCompany and Co.Ltd" />
<Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
<Property Id="DiskPrompt" Value="WIXTestSetup Installation [1]"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="WIXTestSetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="MyCompany" Name = "MyCompany" >
<Directory Id="INSTALLFOLDER" Name="WIXTestSetup" />
</Directory>
</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="MainExecutable" Guid="4BFF8919-9C07-4BBE-BD1C-46AB49524566">
<!-- TODO: Insert files, registry keys, and other resources here. -->
<File Id="WIxTestExe" Name ="WIXTest.exe" DiskId="1" Source="D:\PROJETS VISUAL STUDIO\Projects\MyFirstWIXProject\MyFirstWIXProject\bin\Debug\MyFirstWIXProject.exe" KeyPath="yes" />
</Component>
<Component Id="ProgramFilesFolder" Guid="53B3FC8A-9D2B-4CDD-BE68-D155435C6163">
<RemoveFolder Id="ProgramFilesFolder" On="uninstall"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
I also check "CodePage" and "SummaryCodePage" but I've not resolve the build problem.
I've tried that too : WiX ICE validation errors
Have you some Idea to fix it ?
In the database validation step, light.exe tries to reopen the MSI file for read/write access While anti virus scanning the new msi file that been created.
Try to do the following:
Exclude the temporary directory from the real-time virus scan.
Adding English input language in Windows' regional settings.
Disable the ICE validation. Go to the wix Project Properties, Tool Settings, then checked "Suppress ICE validation".
You can check discussion related to this topic, here:
Error LGHT0301: Failed to open the database

Writing to 32 bit registry values in a 64 bit O

I am facing an issue while using Wix Installer for 64 bit machines having 64 bit Chrome.
I need to write to both the Wow6432 Path and regular path (HKLM\Software\Google\Chrome) for 64 bit machines to enable our app extension in Chrome (Chrome 32 reads from Wow6432 Path and Chrome 64 reads from Regular path). I have the following code snippet
<Component Id='RegistryComponents' Guid='{771E66CF-7086-4A56-AAF9-3571ADBEB9AA}' Win64='no'>
<RegistryKey Id='ChromeExtnInstaller' Root='HKLM' Key='Software\Google\Chrome\Extensions\$(var.Extension)' Action='createAndRemoveOnUninstall'>
<RegistryValue Name='update_url' KeyPath='yes' Type='string' Value='https://clients2.google.com/service/update2/crx' />
</RegistryKey>
<RegistryKey Id='NativeMessagingHost' Root='HKLM' Key='Software\Google\Chrome\NativeMessagingHosts\<NM_ID>' Action='createAndRemoveOnUninstall'>
<RegistryValue Type='string' Value='[INSTALLDIR]<Value>' />
</RegistryKey>
<RemoveRegistryKey Action='removeOnUninstall' Root='HKLM' Key='Software\Google\Chrome\Extensions\$(var.Extension)'/>
<RemoveRegistryKey Action='removeOnUninstall' Root='HKLM' Key='Software\Google\Chrome\NativeMessagingHosts'/>
</Component>
<?if $(var.Platform)=x64 ?>
<Component Id='RegistryComponents64' Guid='{20A0BA25-0EFC-49F5-8945-24F084EC3635}' Win64='yes'>
<RegistryKey Id='ChromeExtnInstaller64' Root='HKLM' Key='Software\Google\Chrome\Extensions\$(var.Extension)' Action='createAndRemoveOnUninstall'>
<RegistryValue Name='update_url' KeyPath='yes' Type='string' Value='https://clients2.google.com/service/update2/crx' />
</RegistryKey>
<RegistryKey Id='NativeMessagingHost64' Root='HKLM' Key='Software\Google\Chrome\NativeMessagingHosts\com.sling.wbsp' Action='createAndRemoveOnUninstall'>
<RegistryValue Name='Default' Type='string' Value='[INSTALLDIR]com.sling.wbsp.json' />
</RegistryKey>
<RemoveRegistryKey Action='removeOnUninstall' Root='HKLM' Key='Software\Google\Chrome\Extensions\$(var.Extension)'/>
<RemoveRegistryKey Action='removeOnUninstall' Root='HKLM' Key='Software\Google\Chrome\NativeMessagingHosts'/>
</Component>
<?endif?>
And in the Feature Section:
<ComponentRef Id="RegistryComponents"/>
<?if $(var.Platform)=x64 ?>
<ComponentRef Id="RegistryComponents64"/>
<?endif?>
When I try to install using a x86 Installer on a 64 bit machine, only the Wow6432Node keys are updated. Because of this, 64 bit Chrome cannot get the Extension installed. If I make a 64 bit Installer, Chrome 64 works but Chrome 32 fails. How can I ensure that, using a standard 32 bit Installer, I can write to both the paths? Can anyone tell me what I am doing wrong? Appreciate your help.
The general situation is that 32-bit MSIs can contain only 32-bit components, and that includes the registry:
http://msdn.microsoft.com/en-us/library/aa367451(v=vs.85).aspx
and separate MSIs are needed for different architectures:
http://blogs.msdn.com/b/heaths/archive/2008/01/15/different-packages-are-required-for-different-processor-architectures.aspx
If you have a 64-bit setup you should be able to write to the 32-bit registry as well as the 64-bit registry, as that top link says, so I guess that what you are missing in your 64-bit setup is a component that writes to the native 64-bit registry, and another identical entry that has Win64="no" for the 32-bit registry.

WIX uninstall doesn't remove site on Windows server 2008 R2

I have installer which setups web site. Installer is implemented using WIX 3.5. The components installing site are in listing below:
<DirectoryRef Id="TARGETDIR">
<Directory Id="WWWROOT">
</Directory>
</DirectoryRef>
<Property Id="WWWROOT" Value="C:\inetpub\wwwroot">
<RegistrySearch Id="FindInetPubFolder" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="PathWWWRoot" Type="directory" />
</Property>
<Component Id="CC_AppPoolConfigure" Guid="YOURGUID-9558-4CAE-A928-EACD27D69A0D" KeyPath="yes" Permanent="no">
<iis:WebAppPool Id="CC_AppPool" Name="[SITE_APP_POOL]" ManagedRuntimeVersion="v4.0" ManagedPipelineMode="integrated" />
</Component>
<Component Id="CC_Iis6SiteConfigure" Guid="YOURGUID-13E2-4980-A55A-E37E3E06FB67" KeyPath="yes" Permanent="no">
<Condition><![CDATA[Installed OR (IISMAJORVERSION AND (IISMAJORVERSION = "#6"))]]></Condition>
<iis:WebSite Id="CC_WebSite_IIS6" Description="[SITE_NAME]"
AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes"
Directory="WWWROOT" ConnectionTimeout="360" SiteId="[SITE_ID]">
<iis:WebVirtualDir Id="CC_Site_IIS6_VDir" Directory="SITE_INSTALLDIR" Alias="[SITE_VIRT_DIR]">
<iis:WebApplication Id="CC_IIS6_WebApp" Name="[SITE_APP_NAME]" WebAppPool="CC_AppPool" >
<iis:WebApplicationExtension Verbs="GET,HEAD,POST" CheckPath="no" Script="yes" Executable="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" />
</iis:WebApplication>
<iis:WebDirProperties Id="CC_Site_IIS6_Properties" WindowsAuthentication="yes" AnonymousAccess="yes"/>
</iis:WebVirtualDir>
<iis:WebAddress Id="CC_Site_IIS6_Header_Bindings" Port="[SITE_PORT]" Header="[SITE_HEADER]" />
</iis:WebSite>
</Component>
<Component Id="CC_IIS6_Config_Extentions" Guid="YOURGUID-009A-4545-8D4D-EC5437D7332F" KeyPath="yes" Permanent="yes">
<Condition><![CDATA[IISMAJORVERSION AND (IISMAJORVERSION = "#6")]]></Condition>
<iis:WebServiceExtension Id="CC_ExtensionASP4" Group="ASP.NET v4.0.30319" Allow="yes" File="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" Description="ASP.NET v4.0.30319"/>
</Component>
<Component Id="CC_Iis7Site" Guid="YOURGUID-1738-476A-945F-A97721F5ECFC" KeyPath="yes" Permanent="no">
<Condition><![CDATA[IISMAJORVERSION AND (IISMAJORVERSION >= "#7")]]></Condition>
<iis:WebSite Id="CC_WebSite_IIS7" Description="[SITE_NAME]"
AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes"
Directory="WWWROOT" ConnectionTimeout="360" SiteId="[SITE_ID]">
<iis:WebVirtualDir Id="CC_Site_IIS7_VDir" Directory="SITE_INSTALLDIR" Alias="[SITE_VIRT_DIR]">
<iis:WebApplication Id="CC_IIS7_WebApp" Name="[SITE_APP_NAME]" WebAppPool="CC_AppPool"></iis:WebApplication>
<iis:WebDirProperties Id="CC_Site_IIS7_Properties" WindowsAuthentication="yes" AnonymousAccess="yes"/>
</iis:WebVirtualDir>
<iis:WebAddress Id="CC_Site_IIS7_Header_Binding" Port="[SITE_PORT]" Header="[SITE_HEADER]" />
</iis:WebSite>
</Component>
As you can see, site needs to be installed on IIS 6, IIS 7 and IIS 7.5. Installation is fine on all listed environments. Installer performs per-machine installation. I use deffered custom actions for enabling required IIS components etc, so installer first is runned without admin permissions and asks for them when button "Install" is clicked.
But there is a problem uninstalling product using the same installer file which was used to install it - Site and virtual directory left on IIS. It only occurs on Windows Server 2008 R2 (IIS 7.5) when UAC is enabled and only when uninstalling through running installer file and selecting option "Remove" in first dialog. I tested this on few environments (Windows Server 2003, 2003 R2, 2008 x86, 2008 x64, 2008 R2) and it looks like 2008 R2 is the only environment where the issue is present. Other investigations shown that disabling UAC solves the problem. Uninstalling product through control panel or running the same msi from command line with uninstall parameter doesn't have this issue too. So there is very narrow case where issue is present, but it is still important.
I'm almost sure that the problem is because of UAC restrictions: maybe installer tries to uninstall site before UAC dialog is shown to give permissions. But I can't understand how can I fix it. Any help will be appreciated.
If you have better approach to installing site on so various environments, I would be happy to hear it too - my invented wheel probably isn't the best =).
If you need uninstall log, it is here:
We had the same issue and solved it by changing properties that contains Web site and application names to Secure="yes". In your case, make sure that:
<Property Id="SITE_NAME" Secure="yes">
<Property Id="SITE_APP_NAME" Secure="yes">

Setting the AppPool of a WebSite element in WiX 3.6

I have a WiX installer which sets up a couple of root IIS websites each of which has a number of WebApplications. We have a separate AppPool for each root and put each of the WebApplications into that AppPool.
Unfortunately I can't find a way of making sure the WebSites go into their required AppPools and WiX insists on putting them in DefaultAppPool.
Am I missing anything here?
<Component Id="INPUT" Guid="{43302D85-55B5-4C99-8C07-8AF5ED419E0A}" Directory="dirBBD4B479DF2AD0441616B5EB11867FA6" KeyPath="yes">
<iis:WebAppPool Id="INPUTPool" Name="RCMInput" ManagedPipelineMode="integrated" ManagedRuntimeVersion="v4.0"/>
</Component>
<Component Id="INPUTSITE" Directory="dirBBD4B479DF2AD0441616B5EB11867FA6" Guid="{E508497A-C485-4EB8-8A91-4299BD46291B}" KeyPath="yes">
<iis:WebSite Id="INPUTROOT" Description="RCMInput" Directory="dirBBD4B479DF2AD0441616B5EB11867FA6" AutoStart="yes" >
<iis:WebAddress Id="INPUTROOTADDRESS" IP="[RCMINPIP]" Port="443" Secure="yes" Header="[RCMINPHOST]" />
<iis:WebVirtualDir Id="INPUTVD" Alias="InputApp" Directory="dir0AC030D54BBE340DFFCC71C2724F6BF1">
<iis:WebApplication Id="INPUTWEBAPP" Name="InputApp" WebAppPool="RCMInpAppPool">
<iis:WebApplicationExtension CheckPath="no" Extension="svc" Executable="[NETFRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" Verbs="GET,HEAD,POST,PUT,DELETE"/>
</iis:WebApplication>
</iis:WebVirtualDir>
<iis:WebVirtualDir Id="INPUTVD2" Alias="Administration" Directory="dir78ADFB9F5CBB65D9A3E21EAB7F4C5911">
<iis:WebApplication Id="INPUTWEBAPP2" Name="Administration" WebAppPool="RCMInpAppPool">
<iis:WebApplicationExtension CheckPath="no" Extension="svc" Executable="[NETFRAMEWORKROOT]v2.0.50727\aspnet_isapi.dll" Verbs="GET,HEAD,POST,PUT,DELETE"/>
</iis:WebApplication>
</iis:WebVirtualDir>
</iis:WebSite>
</Component>
I would guess that when you reference the AppPool name "RCMInput" in the WebApplication, it cannot resolve it and is defaulting the the Default App Pool. Have you tried running your MSI with logging turned on and see if that gives any extra detail?
From command line
msiexec /i install.msi -L*v install.log
There's a good blog post on deploying web apps in WiX at http://ranjithk.com/2009/12/17/automating-web-deployment-using-windows-installer-xml-wix/ where he defines the AppPool in the same component as the WebApplication.
Not sure if it has changed in 3.6 but for 3.5 when the AppPool is referenced in WebApplication use the Id, instead of using RCMInpAppPool use INPUTPool.
Here's an excellent example
I was having the same problem, but I finally find a solution for it. Instead of nesting a WebApplication (which is referencing your app pool) inside a WebVirtualDir, put it directly inside your website. So, if you have this:
<iis:WebSite Id='WebSite' Description='My Website' Directory="WebsiteDir">
<iis:WebAddress Id='WebAddress' Port='80' />
<iis:WebVirtualDir Id="VirtualDir" Alias="mywebsite" Directory="WebsiteDir">
<iis:WebApplication Id="WebApplication" Name="MyWebApplication" WebAppPool="MyWebAppPool" />
</iis:WebVirtualDir>
</iis:WebSite>
Replace with this:
<iis:WebSite Id='WebSite' Description='My Website' Directory="WebsiteDir">
<iis:WebAddress Id='WebAddress' Port='80' />
<iis:WebVirtualDir Id="VirtualDir" Alias="mywebsite" Directory="WebsiteDir" />
<iis:WebApplication Id="WebApplication" Name="MyWebApplication" WebAppPool="MyWebAppPool" />
</iis:WebSite>

Resources