Search code examples
wixwindows-installerwix3.7

WiX and ARPINSTALLLOCATION


I want my MSI package to write the value InstallLocation into HKEY_LOCAL_MACHINE\SOFTWARE\\(Wow6432Node)\Microsoft\Windows\CurrentVersion\Uninstall\\(GUID). You should also see this value in the Add/Remove Programs Control Panel (column Location).

To set this value via WiX, I read that the property ARPINSTALLLOCATION should be set by a custom action. I reduced the <Product> to a minimum. This is how it looks like:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*" 
           Name="MyApplication"
           Language="1033" 
           Version="!(bind.FileVersion.MyApplication.exe)" 
           Manufacturer="Me"
           UpgradeCode="db37f5dc-68c5-46ee-bbdf-704ff68b70db">
    <Package InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Languages="0" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <!-- use SetProperty as suggested by Rolo -->
    <SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="CostFinalize" />
    <Feature Id="ProductFeature" Title="MyApplication" Level="1">
      <ComponentGroupRef Id="MyApplication.Files.AllRequired" />
    </Feature>
  </Product>
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="MyApplication" />
      </Directory>
    </Directory>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="MyApplication.Files.AllRequired">
      <Component Id="ProductComponent" 
                 Guid="90EA8F1C-77D2-40E1-81AD-44B076EFAB9D" 
                 Directory="INSTALLDIR">
        <File Id="MyApplication.exe" Source="$(var.MyApplication.TargetDir)\MyApplication.exe" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

The MSI is bundled within a WiX Standard Bootstrapper.


Solution

  • You should execute your custom action in both sequences (InstallExecuteSequence and InstallUISequence) and sequence it after CostFinalize.

    You can simplify this using something like this:

    <SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="CostFinalize" />