Search code examples
cmdwix

Why is my WiX generated msi installing to the wrong directory


I'm trying to write a batch script using the Wix command line toolset to build an .msi file from both a Heat generated and a custom .wxs file.

The batch script below is currently building the .msi file correctly for the most part. However, when ran it's installing the binaries straight to the C: drive, instead of installing them to the installation folder specified in the custom wxs file.

Can someone point out what I'm missing because I'm at a loss.

Batch script:

"%WIX%bin\heat" dir .\bin\ -srd -gg -pog:Binaries -cg AppBinComponentGroup -out .\AppHeatGen.wxs
"%WIX%bin\candle" .\*.wxs -o .\wixbuild\wixobj\
"%WIX%bin\light" -b .\bin\ .\wixbuild\wixobj\*.wixobj -o .\wixbuild\wixbin\AppInstaller.msi

Custom wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="App" Language="1033" Version="1.0.1.0">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <MediaTemplate EmbedCab="yes" />

        <Feature Id="ProductFeature" Title="App" Level="1">
            <ComponentGroupRef Id="AppBinComponentGroup" />
        </Feature>
    </Product>

    <Fragment>
    <SetDirectory Id="APPLICATIONFOLDER" Value="C:\InstallDir" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="APPLICATIONFOLDER">
        <Directory Id="INSTALLFOLDER" Name="App" />
            </Directory>
        </Directory>
    </Fragment>
</Wix>

Solution

  • After trying out different things with the wix scripts, I found that the heat command was setting all of the Component Directory values to TARGETDIR.

    The fix was to update the heat command to include a -dr tag w/ the the desired installation folder id as the value.

    "%WIX%bin\heat" dir .\bin\ -dr INSTALLFOLDER -srd -gg -pog:Binaries -cg AppBinComponentGroup -out .\AppHeatGen.wxs