简体   繁体   中英

WiX Installer removes config file values on repair

I have created an installer which copies a config.ini and asks the user for values which are then inserted into the ini file. This works fine during a fresh install and major/minor upgrades.

<Component Id="ConfigIni" Guid="GUID-GOES-HERE" DiskId="1">
    <File Id="ConfigIniFile"
             Name="config.ini"
             Source="../../artefacts/etc/template-config.ini"
             KeyPath="yes"/>
    <IniFile Id="ValueOne"
             Action="addLine"
             Directory="ETC"
             Section="sectionone"
             Name="config.ini"
             Key="valueone"
             Value="[VALUEONEPROPERTY]" />
    <IniFile Id="ValueTwo"
             Action="addLine"
             Directory="ETC"
             Section="sectiontwo"
             Name="config.ini"
             Key="valuetwo"
             Value="[VALUETWOPROPERTY]" />
</Component>

However, if a user tries to install the same version of the product which is already installed, the installer enters repair mode. I'm not sure how repair mode works, but in the case of the config.ini file, it seems to be deleting the one with populated values, copying it again, and because it's a repair it's not got any user values to populate the config.ini file with, so the file is blank.

Is there any way of getting the installer to ignore this file on repair, or get the original user values?

The basic problem is the property values not being preserved. There is no magic that automatically saves the values of properties between an install and a repair (or adding new features etc). The problem is not that the file is being replaced because Windows will not replace files that have been modified with user data.

In WiX, use the "remember property" pattern to save the values of properties so that they are restored in these maintenance cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM