[wix-users] How to Update existing configuration

Edwin Castro egcastr at gmail.com
Wed Apr 26 16:17:00 PDT 2017


You could write an immediate mode custom action to read the settings
from the config file during an upgrade and save the current setting
values in public properties. Perhaps this custom action can set the
public properties with default values so that you can run the custom
action for both installs and upgrades.

Then add <util:XmlConfig/> elements to the component for the config
file. These <util:XmlConfig/> elements would then be responsible for
setting the values previously saved in public properties by the
immediate mode custom action above. You can do this for all settings
you need to preserve.

Of course, the catch here is that you need to know ahead of time all
settings that should be preserved.

There is no need to backup files with this approach as windows
installer already creates a back up for rollback.

--
Edwin G. Castro


On Wed, Apr 26, 2017 at 3:22 PM, Carlos Sosa <carlos.sosa.us at outlook.com> wrote:
> Hello, Well I have been trying so many things for hours with no luck.
> ANY help is really appreciated.
>
> I tried custom actions (no success)
> I tried copyfile (no success)
> I tried a Bundle (can create the back up using a .bat but having other problems like version and overwriting the old .config)
>
> I think I'm being impatient and just jumping around too much, so I'm going to go back to the copyfile option, because the only thing I want to do at this point is to BackUp the .config before the new one overwrites it.
> I need to copy the configuration file "myApp.Config" form the Installation directory (when doing an upgrade the file is already there) and copy it some where else.
>
> 1. This is giving me errors: SchemaValidationFailed....
>
> <Fragment>
>
>     <Property Id="SourceFileDir" Value="C:\Program Files (x86)\Packsize PackNet.Cube\" />
>     <Property Id="DestFileDir" Value="C:\Users\%username%\Desktop\MyAppBackup\" />
>
>       <Component Id="Component1" Guid="*" Directory="INSTALLFOLDER">
>       <File Id='FileToCopy' LongName='myApp.config' Source='SourceFileDir'>
>       </File>
>        <CopyFile Id='CopyTask' DestinationProperty='DestFileFolder' DestinationLongName ='myApp.config' FileId='FileToCopy'/>
>       </Component>
>
>     </Fragment>
>
> Once that is fixed, how/where do I call it? From within my Feature Section?
>
> Best Regards.
>
>
>
> -----Original Message-----
> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Farrukh Waheed
> Sent: Wednesday, April 26, 2017 12:00 AM
> To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
> Subject: Re: [wix-users] How to Update existing configuration
>
> Consider using Util extension, which has methods: XMLConfig and XMLFile.
> First one can be used in your case.
> From "preserve the settings", I guess you need to backup existing config file. You could use WIX's  CopyFile to make a copy of existing one.
>
>
>
> On 26 April 2017 at 04:03, Carlos Sosa <carlos.sosa.us at outlook.com> wrote:
>
>>
>> Hello WIX community, I have a xml configuration file as follows:
>>
>> <Fragment>
>>     <!--
>>         Permanent="yes" Don't remove the file
>>         NeverOverwrite="yes" Don't write the file if it already exists
>>         -->
>>     <ComponentGroup Id="ExeConfig" Directory="INSTALLFOLDER" >
>>       <Component Id="MyCompany.MyProgram.exe.config" Guid ="*"
>> Permanent="yes" NeverOverwrite="yes">
>>         <File Name="MyCompany.MyProgram.exe.config"
>> Source="$(var.MyProgram.TargetPath).config" KeyPath="yes"/>
>>       </Component>
>>     </ComponentGroup>
>>   </Fragment>
>>
>> We added a couple of settings to it, how can I add the 2 settings to
>> the "old" xml during upgrade?
>> I need to preserve the setting for the previous version, what would
>> the best route to accomplish this be?
>>
>> Best Regards.
>>
>> ____________________________________________________________________
>> WiX Toolset Users Mailing List provided by FireGiant
>> http://www.firegiant.com/
>>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list