Controlling the sequence of events in a Wixtoolset (.msi) installer

244 views Asked by At

I am creating a Microsoft Installer (.msi file) using the Wixtoolset (Windows Installer XML). This installer must automate the installation of an existing .exe program (named installer.exe below) and copy a custom configuration file (named settings.conf below) to the target directory. In addition the installer must modify the configuration file using the InstallFiles command below. But the timing of events is critical. If the executable installer runs too early, it fails or exhibits strange behavior. And if the executable installer run too late in the install sequence, it overwrites my modified configuration file with the generic values. I believe this can be done by assigning a string to the Before or After property value. What Before or After property assignment will allow the executable to run properly but not overwrite the configuration file I moved by the CopyFile element? Here is my Wixtoolset XML code.

        <Property Id="CONFIGFOLDER"  Value="C:\acme\config" >
        <Feature
            Id="ConfigurationFile" 
            Title="Configuration File" 
            Level="1"
            <ComponentRef Id="CMP_ACME_Config_File" />
        </Feature>
        <DirectoryRef Id="TARGETDIR">
            <Component Id="CMP_ACME_Config_File" Guid="">
                <File
                    Id="ACME_Config" 
                    Source="MySettings.conf" 
                    KeyPath="yes"
                    <CopyFile Id="Copy_ACME_Config" 
                    DestinationProperty="CONFIGFOLDER" 
                    DestinationName="settings.conf" />
                </File>
            </Component>
        </DirectoryRef>
        <Binary 
            Id="InstallerEXE"    
            SourceFile="installer.exe" />
        <CustomAction 
            Id="Launch_Installer" 
            BinaryKey="InstallerEXE" 
            Impersonate="yes"  
            Execute="deferred" 
            ExeCommand=""
            Return="check" />
        <InstallExecuteSequence>
            <Custom Action="Launch_Installer" 
                Before="InstallFiles">
            </Custom>
        </InstallExecuteSequence>
    </Property>
1

There are 1 answers

0
skinnedknuckles On

I can't explain exactly why this works but assigning "InstallFiles" to the "After" property in the "Custom" element seems to do the trick.

     <InstallExecuteSequence>
         <Custom Action="Launch_Installer" 
             After="InstallFiles">
         </Custom>
     </InstallExecuteSequence>