MSI 重大升级覆盖规则 [英] MSI Major Upgrade overwriting rules

查看:26
本文介绍了MSI 重大升级覆盖规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我在某处读过它,但现在找不到来源并且无法确认它:当安装(主要升级)来自 MSI 的更新版本时,如果文件已被修改(由安装程序或用户修改),默认规则是旧文件不会被新版本的相同文件替换?

I think I read it somewhere, but couldn't find the source now and can't confirm it: when install(Major upgrade) a newer version from MSI, if the file has been modified (either by installer or user), the default rule is that old file wouldn't be replaced by the same file from a new version?

我想我也观察到我之前写的安装程序中的行为,但现在经过一些更改后,它似乎总是会替换旧的修改配置文件!

I think also I observed that behavior in the installer I wrote before, but now after a few changes, seems that it will always replace the old modified config files!

产品定义:

    <Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Advanced Software Solution" UpgradeCode="$(var.UpgradeCode)">
        <Package Id="*"  InstallerVersion="200" Description="The web service installer" Compressed="yes" 
             InstallScope="perMachine"/>
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

组件定义:

<Component Id='WebConfigComp' Guid='GUID'>
        <File Id='WebConfigFile' Name='Web.config' Source='$(var.TheWebService.WCF.TargetBinPath)\Web.Distribution.config'
              KeyPath='yes'>
        </File>
      </Component>

安装执行序列

FindRelatedProducts     25
AppSearch               50
LaunchConditions        100
ValidateProductID       700
myScripts_CA            799
CostInitialize          800
FileCost                900
CostFinalize            1000
MigrateFeatureStates    1200
InstallValidate         1400
RemoveExistingProducts  1401
InstallInitialize       1500
BackupCA    Installed   1501
ProcessComponents       1600
UnpublishFeatures       1800
SchedSecureObjectsRollback_x64  VersionNT > 400 1801
RemoveFiles         3500
RemoveFolders       3600
CreateFolders       3700
InstallFiles        4000
InstallServices VersionNT   5800
SchedSecureObjects_x64  NOT REMOVE~="ALL" AND VersionNT > 400   5801
ConfigureIIs    NOT SKIPCONFIGUREIIS AND VersionNT > 400    5999
RegisterUser        6000
RegisterProduct     6100
PublishFeatures     6300
PublishProduct      6400
InstallFinalize     6600
LunchWCFReadme  NOT Installed   6601

更新:我刚刚创建了一个用于测试的新项目,观察到相同的行为(修改后的文件被更新版本的安装程序替换),而没有更改默认的 InstallExecSequence.这可能意味着即使文件版本控制应该适用,但它实际上并没有影响预期的结果,因为如 Glytzhkof 和 PhilDW 指出的那样,旧版本的删除发生得太早是默认的.

Update: I just created a new project for testing, the same behavior observed (the modified file is replaced by the newer version of installer) without change the default InstallExecSequence. Which probably means even though the File Versioning should applies, but it not actually kicked in to affect the result would expected as Remove of old version happened too early be default as Glytzhkof and PhilDW pointed out.

我使用的是目前稳定版的 Wix 3.8,我错过了什么吗?

I am using Wix 3.8, the current stable, did I missed something?

更新 2:到目前为止,我可以确认在 InstallFiles 之后移动 RemoveExistingProducts 将保留修改后的未版本化文件.但问题是似乎 MajorUpgrade

Update2: So far, I can confirm that moving RemoveExistingProducts after InstallFiles will keep the modified unversioned files. But the problem is that seems MajorUpgrade conflict with

  <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallExecute" />
    </InstallExecuteSequence>

我正在添加,错误信息是

I am adding, and the error message is

错误 1 ​​重复符号找到WixAction:InstallExecuteSequence/RemoveExistingProducts".这个通常意味着 Id 是重复的.检查以确保您的所有给定类型(文件、组件、功能)的标识符是独特的.C:\TestDev\MySetupTest\MySetupTest\Product.wxs 5 1 MySetupTest

Error 1 Duplicate symbol 'WixAction:InstallExecuteSequence/RemoveExistingProducts' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique. C:\TestDev\MySetupTest\MySetupTest\Product.wxs 5 1 MySetupTest

这也不是很有帮助.

最终更新:在网上挖了一阵子,找出问题所在:

Final Update: After digging the web thing for a while, find out what the issue is:

默认情况下,MajorUpgrade 在之后安排 RemoveExistingProducts安装验证.您可以使用 Schedule 更改日程安排属性.例如,如果您选择在之后安排它InstallInitialize,它将如下所示:

By default, MajorUpgrade schedules RemoveExistingProducts after InstallValidate. You can change the scheduling using the Schedule attribute. For example, If you choose to schedule it after InstallInitialize, it will look like the following:

<MajorUpgrade
  Schedule="afterInstallInitialize"
  DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit.">

来源:Wix 工具集网站

因此,包含 MajorUpgrade 确实会为您更改 RemoveExistingProducts 序列,这是一个有用的功能,但对我来说却出乎意料.感谢所有的帮助,现在事情开始对我有意义.毕竟是大团圆!

So including of MajorUpgrade will indeed change RemoveExistingProducts sequence for you, which is a useful feature to have, but was unexpected for me. Thanks for all the help, now things starting make sense to me. An happy ending after all!

推荐答案

当主要升级在安装新版本之前卸载现有安装时(在 InstallInitialize 之前删除现有产品),它通常会删除所有最初安装的文件 - 这包括文件可能已被修改.然后安装新版本的新文件包.

When a major upgrade uninstalls an existing installation before the new version gets installed (RemoveExistingProducts before InstallInitialize) it will normally remove all files that were originally installed - this includes files that may have been modified. Then the new version is installed with a fresh bundle of files.

如果在 InstallFinalize 之后安排 RemoveExistingProducts,则新版本文件的安装会先于过时文件的删除.在这种情况下,文件仅在版本化且比安装的文件更新时才会被替换,而对于 txt、pdf 等未版本化的文件...磁盘.

If you schedule RemoveExistingProducts after InstallFinalize the install of the new version's files precedes the removal of obsolete files. In this scenario files are only replaced if they are versioned and newer than installed files, and for unversioned files like txt, pdf, etc... the file replacement rules basically states that the file will only be overwritten if it has not been changed on disk.

因此,在 InstallFinalize 之后移动 RemoveExistingProducts 可能会解决您的文件替换问题",这实际上是您当前的升级策略在卸载和重新安装时修改的文件被删除的情况.

It follows that moving RemoveExistingProducts after InstallFinalize may solve your file "replacement problem" which is really a case of the modified files being deleted during uninstalland reinstalled by your current upgrade strategy.

这篇关于MSI 重大升级覆盖规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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