4

我们使用 WiX 来构建安装包。我是 WiX 技术的新手,目前正在尝试对已安装的应用程序进行重大升级,但位于与以前版本不同的目录位置。例如,如果产品的 v2 安装在 Program Files (x86)\Old_path\Product 上,我想将升级版本 v3 安装在不同的文件夹 C:\Program Files (x86)\New_path\Product 上。

我已修改 msi 属性 INSTALLDIR 以获得新的位置路径。我们尝试更改 InstallExecuteSequence,在 InstallValidate 之后添加 RemoveRegistryValues 以删除注册表中存储的旧路径,并使用 WriteRegistryValues 添加新的注册表值。

<InstallExecuteSequence>
....
    <Custom Action="HxPrepare" Before="InstallValidate">NOT Installed</Custom>
    <RemoveRegistryValues After="InstallValidate" />
    <WriteRegistryValues />
   <Custom Action="HxFinalize" Before="StartServices">NOT Installed</Custom>
....
<InstallExecuteSequence />

但我发现安装过程没有变化,新文件只复制到旧目录路径。即使在修改了 INSTALLDIR 路径之后,我能否知道这条旧路径是从哪里获得的?我们如何在重大升级期间更改安装路径。

回复 PhilDW 的评论:

这是重大升级的正确过程。所有旧版本文件都将被删除。但是在我们的应用程序中,在升级过程中没有浏览对话框来询问新的/必需的安装目录。它只是采用以前的版本路径。这是因为首先我们需要备份低版本的重要设置/用户配置文件,然后在升级版本中使用它们。保存此备份后,我尝试将此备份文件移动到新路径,然后开始复制新文件。我在 HxPrepare 步骤中将此路径更改为 INSTALLDIR,并希望在新目录中继续该过程。但我不知道从哪里只考虑旧路径。

<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="PreventDowngrade" After="FindRelatedProducts">DOWNGRADE</Custom>
<Custom Action="HxInit" After="CostFinalize">NOT Installed</Custom>
<Custom Action="HxPrepare" Before="InstallValidate">NOT Installed</Custom>
<Custom Action="HxFinalize" Before="StartServices">NOT Installed</Custom>
<Custom Action="HxPreUninstall" Before="InstallValidate">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<Custom Action="HxUninstall" After="InstallInitialize">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>

我要执行此安装路径更改的原因是因为我想更改产品制造商名称,并且我希望产品的主要升级发生在新路径上,例如“C:\Program Files (x86)\New_manufacturer\Product installation ” 。我怎样才能做到这一点?

4

0 回答 0