Wix重大升级;不同的组件需要不同的行为

发布于 2024-09-03 17:54:07 字数 1237 浏览 0 评论 0原文

好的!我终于更仔细地确定了我遇到的问题。在我的安装程序中,我试图让设置文件在重大升级时保持完整。我终于让它与设置的建议一起工作,

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

这成功地强制该组件离开原始组件,而不是替换它(如果存在):

<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>

但是,这是一个问题。我在这里列出了另一个组件:

<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>

并且该组件必须在重大升级时更换。到目前为止,我只能通过设置来完成此操作,

<RemoveExistingProducts After="InstallInitialize" />

这破坏了我需要的设置文件的第一个功能。我怎样才能两者兼得?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为你鎻心 2024-09-10 17:54:07

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

如果您确实希望 Windows Installer “不理会该文件”,那么您将需要一个非托管组件,即具有空 GUID 的组件。例如...

<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>

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.

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文