WiX 3.8:两个 MSI 使用相同的注册表值.如何仅在卸载两个 MSI 时删除注册表值? [英] WiX 3.8: Two MSI using the same registry values. How to delete registry values only if both MSI are uninstalled?

查看:52
本文介绍了WiX 3.8:两个 MSI 使用相同的注册表值.如何仅在卸载两个 MSI 时删除注册表值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个共享相同注册表值的 MSI 应用程序(app1.msiapp2.msi).两个 MSI 都引用了一个包含所有自定义操作和内容的 dll.我正在使用 WiX 3.8.这些注册表值是针对解决方案自定义的.

I have two MSI applications (app1.msi and app2.msi) that share the same set of registry values. Both MSI are referencing a dll which contains all custom actions and stuff. I am using WiX 3.8. These registry values are custom for the solution.

如果两个应用程序都被删除,我需要找到一种方法让卸载过程仅删除注册表值.现在,每当我删除 app1app2 时,注册表值都会被删除,除非我卸载并重新安装,否则其他应用程序将无法使用.

I need to find a way for the uninstall process to ONLY remove the registry values if both applications are removed. Right now, whenever I remove either app1 or app2 the registry values are removed, leaving the other application unusable unless I uninstall and re-install.

关于如何解决这个问题的任何想法?

Any ideas as to how to solve this problem?

推荐答案

这是一个很常见的问题.问题是您的 MSI 设置都认为他们拥有"有问题的文件和注册表项,因此他们很乐意在卸载时删除它们 - 这显然很清楚.现在该怎么办?

This is a very common question. The problem is that both your MSI setups think they "own" the file and registry keys in question so they happily remove them on uninstall - this is obviously clear. Now what to do about it?

解决方案通常是使用相同的组件 GUID 在两种设置中安装注册表项/文件.实际上,这意味着该组件已注册为共享组件.MSI 的内置机制是合并模块"(您可以构建合并带有 WiX 的模块).您还应该能够使用 WiX 包含文件 - 尽管我必须承认我从未花时间实际尝试过它.本质上,这需要将单个组件放入 WiX 源文件中,然后两个设置都包含该文件,如下所示(使用 WiX 中的预处理器功能):如何将wxi文件包含到wxs中?.

The solution is generally to use the same component GUID to install the registry keys / file in both setups. Effectively this means that the component is registered as a shared component. MSI's built-in mechanism to do this is "merge modules" (you can build merge modules with WiX). You should also be able to use WiX include files - though I have to admit that I have never taken the time to actually try it. Essentially this would entail putting a single component in a WiX source file that is then included by both setups, something like this (using the preprocessor feature in WiX): How to include wxi file into wxs?.

在两个 MSI 文件中使用相同的组件 GUID 后,安装两个产品时其引用计数将为 2.卸载一个产品时,引用计数将减少到 1,因此不会卸载该组件.卸载第二个产品时,一旦达到 0,就会被卸载(除非它被标记为永久组件).

Once the same component GUID is used in both MSI file, the reference count for it will be 2 when both products are installed. When one product is uninstalled the reference count will be reduced to 1 and the component will hence not be uninstalled. Once it reaches 0 when the second product is uninstalled, it will be uninstalled (unless it is marked as a permanent component).

了解组件引用计数是了解 MSI 的关键.如果您花时间彻底阅读它,这里有一个答案可能会有所帮助(我想我推荐这个 - 请给它一次):在 wix 中更改我的组件 GUID?strong>(请务必阅读此答案,看看它是否仍然有意义).

Understanding component reference counting is key to understanding MSI. There is an answer here that might help if you take the time to read it thoroughly (I think I recommend this - please give it a once-over): Change my component GUID in wix? (please do read this answer, see if it still makes sense).

现在更复杂的是:在野外"部署了旧的 MSI 文件意味着从现在开始设置稳定的组件 GUID 不一定有助于解决问题,因为在安装新的 MSI 时会卸载旧的 MSIMSI 在卸载时仍认为它拥有"注册表项 - 因此将删除它.只有当您的设置知道"该组件​​是共享的并且其注册表项应该被保留时,问题才会解决.

And now a further complication: having deployed your old MSI files "in the wild" means that setting a stable component GUID from now on will not necessarily help to sort out the problem since your old MSI being uninstalled as you install your new MSI still thinks it "owns" the registry key when it is being uninstalled - and hence will delete it. The problem is only solved when both your setups "know" that the component is shared and its registry keys should be left alone.

在我详细说明之前,这些 MSI 文件是实时的吗?如在野外发布,还是仍在开发中?

Before I elaborate this, are these MSI file live? As in published in the wild, or are you still in development?

为了超越自己:如果您可以更改注册表项的位置(例如从 HKLM\Software\Company\MyProductHKLM\Software\Company\NewProductcode> - 这通常是不可能的),然后还为它设置一个新的组件 GUID,那么你应该解耦"过去的罪恶,你的新 MSI 文件应该共享组件正确.

To get ahead of myself: if you can change the location of the registry key (For example from HKLM\Software\Company\MyProduct to HKLM\Software\Company\NewProduct - which is usually not possible) and then also set a new component GUID for it, then you should be "de-coupled" from the sins of the past and your new MSI files should share the component properly.

说了这么多,我想问一下这些注册表设置是在HKCU还是在HKLM?通常不建议将设置写入 HKCU 表单 MSI 设置 - 您应该在应用程序首次启动时填充 HKCU.这种方法可以解决许多困难的部署问题 - 或者防止它们永远存在.

With all that being said, I want to ask if these registry settings are in HKCU or in HKLM? It is generally not recommended to write settings to HKCU form MSI setups - you should rather populate HKCU when your application is first launched. This approach can solve a lot of hard deployment problems - or prevent them from ever existing.

这篇关于WiX 3.8:两个 MSI 使用相同的注册表值.如何仅在卸载两个 MSI 时删除注册表值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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