简体   繁体   中英

Wix keep app setting file on upgrade

I am using Wix for creating an .msi for my installation. I want to keep a config file when the msi installer does a major upgrade.

This are the relevent parts from my Product.wxs file: My upgrade attribute:

<MajorUpgrade      
  Schedule="afterInstallInitialize"
  DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

And the component that by my understanding should prevent the removal of my config file:

<DirectoryRef Id="INSTALLFOLDER">
  <Directory Id="Content" Name="Content">
  <Component Id="Config" Guid="432FF769-1011-47CF-BFFD-0BF780768C45">      
    <File Source="$(var.MO.Packing.Wpf.TargetDir)\Content\StationConfig.xml" Name ="StationConfig.xml"
      Id="config" KeyPath="yes" />
  </Component>
 </Directory>
</DirectoryRef>

Adding my Feature attribute incase it is relevent:

<Feature Id="MainApplication" Title="Main Application" Level="1">
  <ComponentRef Id="myapplication.exe" />
  ...
  <ComponentRef Id="Config" />
  ...
</Feature>

In creating this logic I followed this guide: http://blogs.msdn.com/b/astebner/archive/2008/10/19/9006538.aspx

Also read some other questions and sources: How to keep a config file when major upgrade in wix v3.8?

https://msdn.microsoft.com/library/aa371197.aspx

and some more...

Can anyone identify the problem?

I would add any other relevant data to my question if necessary.

Any help is appreciated!

You haven't said precisely what the problem is, so i'll assume that the config files are being replaced with ones from the new upgrade install.

The rule you're trying to take advantage of is this one:

https://msdn.microsoft.com/en-us/library/aa370531(v=vs.85).aspx

There's a related rule if there is a hash check, but the date rule still applies.

So you just need to arrange for the Major Upgrade sequencing to be "early", such as after InstallInitialize. Then the upgrade installs on top of the older product, following the file replacement rules. The older modified config files won't be replaced.

If this isn't working then, maybe the files (in the older product) were not changed after they were first installed, so you're presumably just installing another copy snd nothing is lost. Do the upgrade with a verbose log and look for the file names and see what it says about overwrite:

msiexec /i [path to msi file] /l*vx [path to a text log file]

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