[英]WIX MSI: I Want to show a message to user "Product is already Installed" if user runs the installer again
I am creating an MSI installer, during testing the same if I am running the installer for the first time the installer works as expected.我正在创建一个 MSI 安装程序,在测试过程中,如果我第一次运行安装程序,安装程序按预期工作。 But when I accidentally run the installer, it uninstalled my files.
但是当我不小心运行安装程序时,它卸载了我的文件。
So, for that, I had modified the condition and added Remove="All" in the condition of the actions.因此,为此,我修改了条件并在操作条件中添加了 Remove="All"。
Which is working fine, but I want to show a message to the User that the product is already installed.哪个工作正常,但我想向用户显示产品已安装的消息。
So, for that, I added the below piece of code:因此,为此,我添加了以下代码:
<Upgrade Id='<<Upgrade Code>>'>
<UpgradeVersion OnlyDetect='yes' Property='SELFFOUND'
Minimum='1.0.1' IncludeMinimum='yes' Maximum='1.0.1' IncludeMaximum='yes' />
<UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND'
Minimum='1.0.1' IncludeMinimum='no' />
</Upgrade>
<CustomAction Id='AlreadyUpdated' Error='[ProductName] is already installed.' />
.....
.....
.....
.....
.....
<InstallExecuteSequence>
<Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
</InstallExecuteSequence>
But when running this, the installer is still running for the second time and not giving the message.但是当运行这个时,安装程序仍然在第二次运行并且没有给出消息。
On checking the logs, could see that the "FindRelatedProducts" skipped with the below message:在检查日志时,可以看到“FindRelatedProducts”跳过了以下消息:
MSI (c) (F4:1C) [06:18:04:806]: Doing action: FindRelatedProducts
MSI (c) (F4:1C) [06:18:04:806]: Note: 1: 2205 2: 3: ActionText
Action 6:18:04: FindRelatedProducts. Searching for related applications
Action start 6:18:04: FindRelatedProducts.
MSI (c) (F4:1C) [06:18:04:806]: Skipping FindRelatedProducts action: not run in maintenance mode
Action ended 6:18:04: FindRelatedProducts. Return value 0.
and和
MSI (s) (18:14) [06:18:05:500]: Running ExecuteSequence
MSI (s) (18:14) [06:18:05:500]: Doing action: FindRelatedProducts
MSI (s) (18:14) [06:18:05:500]: Note: 1: 2205 2: 3: ActionText
Action 6:18:05: FindRelatedProducts. Searching for related applications
Action start 6:18:05: FindRelatedProducts.
MSI (s) (18:14) [06:18:05:507]: Skipping FindRelatedProducts action: already done on client side
Action ended 6:18:05: FindRelatedProducts. Return value 0.
The condition in AlreadyUpdated custom action also does not satisfy. AlreadyUpdated 自定义操作中的条件也不满足。
MSI (s) (18:14) [06:18:05:737]: Doing action: PublishProduct
MSI (s) (18:14) [06:18:05:737]: Note: 1: 2205 2: 3: ActionText
Action 6:18:05: PublishProduct. Publishing product information
Action start 6:18:05: PublishProduct.
PublishProduct:
MSI (s) (18:14) [06:18:05:752]: Re-publishing product - installing new package with existing product code.
Action ended 6:18:05: PublishProduct. Return value 1.
MSI (s) (18:14) [06:18:05:752]: Skipping action: AlreadyUpdated (condition is false)
Is there any way to achieve this requirement?有什么办法可以达到这个要求吗? Am I doing something wrong?
难道我做错了什么?
Custom Action Complexity : First a word on custom actions and their complexity.
自定义操作复杂性:首先介绍自定义操作及其复杂性。 Please read the first paragraphs here: Why is it a good idea to limit the use of custom actions in my WiX / MSI setups?
请阅读此处的第一段: 为什么在我的 WiX/MSI 设置中限制使用自定义操作是个好主意?
Wrong Conditioning : This basically means your conditions are incorrect so the custom actions run in installation modes where they should not.错误的调节:这基本上意味着您的条件不正确,因此自定义操作在它们不应该的安装模式下运行。 There are many installation modes you should test in when you try to use complex conditions (or any condition for that matter):
1. fresh install
, 2. repair
, 3. modify
, 4. self-repair
, 5. patching
, 6. uninstall
, 7. major upgrade invoked uninstall
, etc...当您尝试使用复杂条件(或任何与此相关的条件)时,您应该测试多种安装模式:
1. fresh install
2. repair
3. modify
4. self-repair
5. patching
6. uninstall
7. major upgrade invoked uninstall
等...
In your case some custom actions run on maintenance run as well as during fresh / first installation.在您的情况下,一些自定义操作在维护运行以及全新/首次安装期间运行。 This is a very common problem.
这是一个很常见的问题。 The solution is either to eliminate the custom actions by improving the setup, or to improve conditions so they actually work in any installation mode.
解决方案要么通过改进设置来消除自定义操作,要么改进条件,使它们在任何安装模式下都能实际工作。 Obviously.
明显地。
Condition Debugging : Conditions are hard to get right.条件调试:条件很难做到正确。 I like to test them using message boxes.
我喜欢使用消息框测试它们。 The bottom section here shows how you can do so: How to execute conditional custom action on install and modify only?
此处的底部显示了如何执行此操作: 如何仅在安装和修改时执行有条件的自定义操作? - then you run the setup in different modes and look for the dialog boxes.
- 然后在不同模式下运行安装程序并查找对话框。 When they show up the condition on the custom action is true.
当它们出现时,自定义操作的条件为真。
Complex Conditions : Here is an answer on why old custom actions are used for a new setup: Wix Tools update uses old custom actions .复杂条件:这是关于为什么旧的自定义操作用于新设置的答案: Wix 工具更新使用旧的自定义操作。
Unexpected Behavior : A special note on the properties UPGRADINGPRODUCTCODE
and WIX_UPGRADE_DETECTED
.意外的行为:在属性的特殊音符
UPGRADINGPRODUCTCODE
和WIX_UPGRADE_DETECTED
。 Please read this: Run Wix Custom action only during uninstall and not during Major upgrade - these quirks affect how many times a custom action runs during a major upgrade scenario.请阅读: 仅在卸载期间而不是在主要升级期间运行 Wix 自定义操作- 这些怪癖会影响自定义操作在主要升级方案期间运行的次数。 Some very surprising effects here for people.
这里有一些非常令人惊讶的效果。 Use your message box debugging?
用你的消息框调试?
Links:链接:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.