Wix重大升级;不同的组件需要不同的行为 [英] Wix major upgrade; need different behaviors for different components

查看:33
本文介绍了Wix重大升级;不同的组件需要不同的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的!我终于更仔细地确定了我遇到的问题.在我的安装程序中,我试图让设置文件在主要升级时保持完整.我终于得到了这个与设置的建议

Okay! I have finally more closely identified the problem I'm having. In my installer, I was attempting to get a settings file to remain intact on a major upgrade. I finally got this to work with the suggestion to set

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

这成功地强制这个组件离开原来的,如果它存在就不会替换它:

This is successful in forcing this component to leave the original, not replacing it if it exists:

<Component Id="Settings" Guid="A3513208-4F12-4496-B609-197812B4A953" NeverOverwrite="yes">
    <File Id="settingsXml" KeyPath="yes" ShortName="SETTINGS.XML" Name="Settings.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Settings\settings.xml" Vital="yes" />           
</Component>

然而,这是一个问题.我在这里列出了另一个组件:

However, this is a problem. I have another component listed here:

<Component Id="Database" Guid="1D8756EF-FD6C-49BC-8400-299492E8C65D" KeyPath="yes">
    <File Id="pathwaysMdf" Name="Pathways.mdf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.mdf" Vital="yes"/>
<File Id="pathwaysLdf" Name="Pathways_log.ldf" DiskId="1" Source="\\fileserver\Shared\Databases\Pathways\SystemDBs\Pathways.ldf" Vital="yes"/>
</Component>

并且必须在重大升级时更换此组件.到目前为止,我只能通过设置

And this component must be replaced on a major upgrade. I can only accomplish this so far by setting

<RemoveExistingProducts After="InstallInitialize" />

这破坏了我需要的设置文件的第一个功能.我怎样才能做到这两点?

This breaks the first functionality I need with the settings file. How can I do both?

推荐答案

问题是 settings.xml 不应该首先安装,你真正想做的是安装一些东西类似于defaultSettings.xml",并且在单独的位置具有用户可编辑的设置,在安装后配置步骤或首次运行时将默认值复制到用户/系统配置.如果用户修改文件并运行修复",那么无论如何它都会被覆盖,这是 Windows Installer 的预期行为.

The problem is that settings.xml shouldn't be installed in the first place, what you really want to do is install something like a 'defaultSettings.xml' and have user-editable settings in a separate location, copying the default to the user/system config in either a post-install configuration step or at first run. If the user modifies the file, and runs a "repair" then it's going to get overwritten anyway, this is the intended behavior of Windows Installer.

如果您真的希望 Windows 安装程序保留文件",那么您将需要一个非托管组件,即具有空 GUID 的组件.比如...

If you really want Windows Installer to "leave the file alone" then you're going to need an unmanaged component, i.e. a component with an empty GUID. Such as...

<Component Id="Settings" Guid="" NeverOverwrite="yes">
    <File Id="settingsXml" KeyPath="yes" ShortName="SETTINGS.XML" Name="Settings.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Settings\settings.xml" Vital="yes" />           
</Component>

这篇关于Wix重大升级;不同的组件需要不同的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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