在 wix v3.8 中进行重大升级时如何保留配置文件? [英] How to keep a config file when major upgrade in wix v3.8?

查看:23
本文介绍了在 wix v3.8 中进行重大升级时如何保留配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 msi 安装程序进行重大升级时保留一个配置文件.对于配置文件,我在安装时进行了更改.代码如下:

I want to keep a config file when the msi installer does a major upgrade. For the config file, I make a change when installing. The code is as follows:

<Component Id="MODIFYCONFIG" Guid="6A1D7762-B707-4084-A01F-6F936CC159CE" Win64="yes">
    <File Id="Application.config" Name="Application.config" Vital="yes" KeyPath="yes" Source="ResourceApplication.config"></File>
    <util:XmlFile Id="SetValueIP" Action="setValue" Permanent="yes" File="[#Application.config]"
         ElementPath="/configuration/applicationSettings/Application.Properties.Settings/setting[[]@name='IpAddress'[]]/value"  Value="[IPADDRESS]" Sequence="1"/>
    <util:XmlFile Id="SetValuePort" Action="setValue" Permanent="yes" File="[#Application.config]"
         ElementPath="/configuration/applicationSettings/Application.Properties.Settings/setting[[]@name='IpPort'[]]/value"  Value="[PORT]" Sequence="2"/>
    <Condition>Not Installed</Condition>
  </Component>
  <Component Id="KEEPCONFIG" Guid="F7F173AA-C2FD-4017-BFBC-B81852A671E7" Win64="yes">
    <RemoveFile Id="ApplicationConfig" Name="Application.config" On="uninstall"/>
    <Condition>(REMOVE=ALL) AND (NOT UPGRADINGPRODUCTCODE)</Condition>
  </Component>

但是当发生重大升级时,文件不会被保留.如何保留修改后的文件?

But when a major upgrade occurs the file is not preserved. How can I preserve the modified file?

推荐答案

这解决了我的问题...配置文件通过次要/主要升级保留,并在卸载时完全删除.

This solved it for me... config file is preserved with minor/major upgrade, and completely removed on uninstall.

参考:http://blogs.msdn.com/b/astebner/archive/2008/10/19/9006538.aspx

来自链接页面的汇总信息...

Summarized info from the linked page...

  1. 每个配置文件都应有自己的组件,其中配置文件被标记为组件的密钥路径. Windows Installer 将使用未版本化的文件替换逻辑.
  2. 在InstallFiles"操作之后添加RemoveExistingProducts"操作.在删除旧 MSI 之前安装所有组件的新版本.当它按此顺序完成时,组件的引用计数将增加到 2,但配置文件不会被替换,除非它们未修改(因为未版本化的文件替换逻辑).当旧的 MSI 被移除时,引用计数会减回到 1,但文件不会被移除,因为引用计数不为 0.
  1. Each config file shall have it's own component, where the config file is marked as the keypath of the component. Unversioned file replacement logic will be used by the Windows Installer.
  2. Add "RemoveExistingProducts" action after the "InstallFiles" action. New versions of all components are installed before removing the old MSI. When it's done in this sequence, the components will have their reference count incremented to 2, but the config files will not be replaced unless they are unmodified (because of unversioned file replacement logic). When the old MSI is removed, the reference count will be decremented back to 1, but the files will not be removed because the reference count are not 0.

这篇关于在 wix v3.8 中进行重大升级时如何保留配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆