In Wix, at reinstall, is there possibility to re-execute an XML update components?

23 Views Asked by At

I have an installer that deploy an executable and a XML config file. I have some properties to override the value in config file. I use the "REMEMBER_ME" pattern to catch the cli args.

Can find here the snippet used.

<Fragment>
    <Property Id="WEB_API_URL" Secure="yes" />

    <!-- Add default value to properties -->
    <Property Id="DEFAULT_WEB_API_URL" Value="http://localhost:9000/api/Element?" />

    <!-- Search in registry an overridden value -->
    <Property Id="REGISTRY_WEB_API_URL">
        <RegistrySearch Id="RegSearchWebApiUrl"
                        Root="HKLM"
                        Key="Software\Company\[ProductName]\Settings"
                        Name="WebApiUrl"
                        Type="raw" />
    </Property>

    <!-- To set the WebApiUrl value with a command line argument -->
    <CustomAction Id="SaveWebApiUrlValue" Property="CMDLINE_WEB_API_URL" Value="[WEB_API_URL]" Execute="firstSequence" />
    <CustomAction Id="SetFromRegWebApiUrlValue" Property="WEB_API_URL" Value="[REGISTRY_WEB_API_URL]" Execute="firstSequence" />
    <CustomAction Id="SetFromCmdWebApiUrlValue" Property="WEB_API_URL" Value="[CMDLINE_WEB_API_URL]" Execute="firstSequence" />
    <CustomAction Id="SetFromDefaultWebApiUrlValue" Property="WEB_API_URL" Value="[DEFAULT_WEB_API_URL]" Execute="firstSequence" />

    <InstallUISequence>
        <Custom Action="SaveWebApiUrlValue" Before="AppSearch" />
        <Custom Action="SetFromRegWebApiUrlValue" After="AppSearch">
            REGISTRY_WEB_API_URL
        </Custom>
        <Custom Action="SetFromCmdWebApiUrlValue" After="SetFromRegWebApiUrlValue">
            CMDLINE_WEB_API_URL
        </Custom>
        <Custom Action="SetFromDefaultWebApiUrlValue" After="SetFromCmdWebApiUrlValue">
            NOT CMDLINE_WEB_API_URL AND NOT REGISTRY_WEB_API_URL
        </Custom>
    </InstallUISequence>
    <InstallExecuteSequence>
        <Custom Action="SaveWebApiUrlValue" Before="AppSearch" />
        <Custom Action="SetFromRegWebApiUrlValue" After="AppSearch">
            REGISTRY_WEB_API_URL
        </Custom>
        <Custom Action="SetFromCmdWebApiUrlValue" After="SetFromRegWebApiUrlValue">
            CMDLINE_WEB_API_URL
        </Custom>
        <Custom Action="SetFromDefaultWebApiUrlValue" After="SetFromCmdWebApiUrlValue">
            NOT CMDLINE_WEB_API_URL AND NOT REGISTRY_WEB_API_URL
        </Custom>
    </InstallExecuteSequence>

    <ComponentGroup Id="CMPG_WebApiUrl" Directory="INSTALLDIR">
        <Component Id='CMP_SetWebApiUrlValue' KeyPath='yes' Guid='{7AC607D2-258E-4E34-A07C-87C7603A6960}'>
            <util:XmlFile Id='XML_SetWebApiUrlValue'
                          File='[INSTALLDIR]myFile.config'
                          Action='setValue'
                          ElementPath='//configuration/GeneralConfiguration/WebApiUrl'
                          Name='value'
                          Value='[WEB_API_URL]'
                          PreserveModifiedDate='yes'
                          Sequence='1' />
        </Component>
        <Component Id='CMP_RegistrySaveWebApiUrl' Guid='{F153C128-5352-44ED-9175-F854E4E37951}'>
            <Condition><![CDATA[REGISTRY_WEB_API_URL <> CMDLINE_WEB_API_URL]]></Condition>
            <!--<Condition><![CDATA[1]]></Condition>-->
            <RegistryKey Root='HKLM'
                         Key="SOFTWARE\Company\[ProductName]\Settings"
                         Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string"
                               Name="WebApiUrl"
                               Value="[WEB_API_URL]"/>
            </RegistryKey>
        </Component>
    </ComponentGroup>
</Fragment>

I tried to set REINSTALL=ALL with the new argument value with no success.

I'm expecting using msiexec /i myInstaller.msi WEB_API_URL="FirstValue" and the config file is update to FirstValue and re-executing msiexec /i myInstaller.msi WEB_API_URL="ReconfiguredValue" and the config file is updated with ReconfiguredValue.

0

There are 0 best solutions below