“隐藏"基于 ALLUSERS/MSIINSTALLPERUSER 的功能 [英] "Hide" Features Based on ALLUSERS / MSIINSTALLPERUSER
问题描述
我有一个安装程序,我正在将其从仅管理员安装转换为 Single Package Authoring 安装程序,能够为当前用户或所有用户安装.我的两个功能需要写入普通用户无法使用的注册表项.它们处理与另一个应用程序的集成,因此我无法将注册表值写入用户空间中的其他位置...它们必须进入该位置.
我不担心用户如果不是管理员就无法安装这两个特定功能,如果没有选择安装程序功能没有问题,但我不想在功能树中显示它们所有并确保它们不包含在完整"安装中.
我看到的解决方案让我在组件周围设置条件,这样组件就不会被安装......或者在功能中放置一个条件,将其级别设置为某个高值.如果 ALLUSERS=2 或 MSIINSTALLPERUSER=1,我如何完全禁用和/或隐藏该功能.
每用户设置:我不会骗你,我会主动避免这种设置.我发现 MSI 的每用户安装结构不理想".它与较差的可维护性(升级、修补等)和许多其他细节有关.页面中间的一些细节.
阅读此答案的其他人的一些链接(我想您已经阅读了这些):
特征条件:话虽如此,您可以使用特征条件根据特定条件是真还是假来取消选择特征.您甚至可以将功能的 Level
设置为 0
,这将在安装过程中完全从 GUI 中隐藏它.你可以试试这个.另请阅读下面的链接答案(粗体).它包含对特征条件的更好解释.
我没有时间对此进行测试,但您可以尝试以下 WiX 模型:
<!--默认安装功能--><条件级别="0"><!--如果条件为真,则不安装功能-->ALLUSERS=2 或 MSIINSTALLPERUSER=1</条件></功能>
这些答案可能会帮助您大致了解这一点:
如何在wix中根据条件设置特征的级别?(
请务必阅读这个
).>- 立>
隐藏特征测试:我将添加一个小片段,您可以用来验证特征隐藏的操作.它通过将其设置为 1 来强制相关条件为真 - 而不是使用可能意外为假的真实条件".
<条件级别="0">1</条件></功能>
这应该在设置 GUI 中隐藏 SupportingFiles 功能,并且也不应该安装它.如果您看到不同的行为,请告诉我.
<小时>自定义操作:要根据 GUI 中所做的更改以交互方式隐藏功能,您可以尝试使用自定义操作来控制功能级别.
我不确定这会起作用.当我有机会时,我会测试.现在只需添加该链接.
更新:我现在无法对此进行调查.我想提醒您在安装期间向数据库添加临时行的可能性.也许这是交互式"隐藏功能的方法.我只是不知道,因为我从未尝试过.这是我在临时记录中找到的第一个链接.底部是链接.不做任何保证.
除此之外,我想您可以使用外部 GUI 启动器.稍后我可能会对此发表评论.我最近写了一篇关于这个问题的文章(外部 GUI).
<小时>一些进一步的参考链接:
I have an installer that I'm converting from being an admin-only installation into a Single Package Authoring installer capable of being installed for the current user or for all users. Two of my features require writing to a registry key that would not be available to a regular user. They deal with integration to another application, so I can't write the registry values somewhere else in user space... They have to go in this location.
I'm not concerned with users not being able to install these 2 specific features if they aren't administrators and the installer functions without issue if they aren't selected, but I want to not show them in the feature tree at all and ensure they aren't included in a "Complete" install.
The solutions I've seen let me put conditions around components so the components wouldn't be installed... or to put a condition inside the feature that would set it's level to some high value. How can I disable and/or hide the feature entirely if ALLUSERS=2 or MSIINSTALLPERUSER=1.
Per-User Setups: I won't lie to you, I actively avoid this sort of setup. I find MSI's per-user installation constructs "not ideal". It relates to poor serviceability (upgrades, patching, etc...) and a number of other details. Some details mid-page here.
Some links for others who read this answer (I think you have read these):
- Nice summary page on single package authoring from Advanced Installer
- Single Package Authoring
- Installation context
- MSIINSTALLPERUSER
Feature Conditions: With that said you can use feature conditions to unselect features based on whether a certain condition is true or false. You can even set the Level
of a feature to 0
which will hide it from the GUI entirely during installation. You could try this. Please also read the linked answer below (bolded). It contains a better explanation of feature conditions.
I don't have time to test this, but here is a WiX mock-up that you can try:
<Feature Id="MyFeature" Level="1"> <!--Default to install feature-->
<Condition Level="0"> <!--Do not install feature if condition is true-->
ALLUSERS=2 OR MSIINSTALLPERUSER=1
</Condition>
</Feature>
These answers might help you get an overview of this:
How to set the level of feature based on condition in wix? (
please do read this one
).
Hide Feature Testing: I will add a little snippet you can use to verify the operation of the feature hiding. It forces the condition in question to be true by setting it to 1 - as opposed to using a "real condition" that can be false unexpectedly.
<Feature Id="SupportingFiles" Title="SupportingFiles" Level="1">
<Condition Level="0">1</Condition>
</Feature>
This should hide the SupportingFiles feature from view in the setup GUI, and it should also not install it. Please let me know if you see a different behavior.
Custom Actions: To interactively hide a feature based on changes done in the GUI, you can try to use custom actions to control the feature levels.
I am not sure this will work. I will test when I get the chance. Just adding that link for now.
UPDATE: I am unable to investigate this right now. I want to alert you to the possibility of adding temporary rows to the database during installation. Perhaps this is the way to go to hide the feature "interactively". I just don't know since I have never tried. Here is the first link I found on temporary records. And towards the bottom here are links. No guarantees.
Other than that I suppose you could use an external GUI launcher. I might comment on this later. I recently wrote about this issue (external GUI).
Some Further Links For Reference:
- How to set the level of feature based on condition in wix?
- Unselected Feature Being Installed
- WiX Checkbox property only working if default value given
这篇关于“隐藏"基于 ALLUSERS/MSIINSTALLPERUSER 的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!