我怎样才能在 WiX 中至少需要两个可选组件之一?
我正在使用 WixUIFeatureTree 为用户提供他们想要安装的应用程序组件的选项...我的功能之一包含两个可选功能,至少必须安装其中之一才能使程序正常工作。我不想强迫用户安装任一特定的,但我不知道如何强迫他们选择至少一个。
这是我当前 WXS 的相关部分:
<Feature Id="Main" Title="Product Name" Level="1" Absent="disallow" Display="expand" AllowAdvertise="no"
Description="This is the application, and is a required component"
>
<ComponentRef Id="Baseline" />
<ComponentRef Id="Shortcuts" />
<Feature Id="Option1" Title="Plugin #1" Level="2" Absent="allow" AllowAdvertise="no">
<ComponentRef Id="Plugin1Component" />
</Feature>
<Feature Id="Option2" Title="Plugin #2" Level="3" Absent="allow" AllowAdvertise="no">
<ComponentRef Id="Plugin2Component" />
</Feature>
</Feature>
我猜我需要在序列的正确位置插入某种自定义操作,以确保选择其中一个进行安装,但不知道该怎么做是这样,或者说是否正确。感谢所有帮助!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我意识到这是一篇旧帖子,但这就是我使用 WIX v3.7 和 UI FeatureTree 解决此问题的方法:
完整的 FeatureTree 覆盖代码:
我希望这可以帮助别人。
I realize this is an old post, but this is how I solved this using WIX v3.7 with the UI FeatureTree:
Full FeatureTree override code:
I hope this helps someone out.
我认为您真正想要在这里做的是在 中添加一个条件。下一步按钮的元素,在满足您的条件之前不会启用它。比如:
我不知道如何根据检查的组件设置这些条件,尽管必须有某种方法来做到这一点,以便稍后安装正确的组件......
I think what you actually want to do here is put a condition in the <Publish> element for the Next button to not enable it until your conditions are met. Something like:
What I don't know is how to set those conditions based on which components are checked, though there has to be some way to do it so that the right components get installed later on...
使用功能状态作为条件怎么样?
类似 (&Option1=2) AND (&Option2=2)
以下是更好理解的链接:
MSI 高级自定义操作
How about using the Feature state as a condition?
Something like (&Option1=2) AND (&Option2=2)
Here is a link for better understanding:
MSI Advanced Custom Actions
我现在没有时间进行技术测试,只是想向您指出 INSTALLLEVEL 属性的方向。这是一个与特征选择相关的相当反直觉的概念。本质上,安装有一个整体的 INSTALLLEVEL,它是 1 到 32,767 之间的一个数字,每个功能都有一个安装级别属性,它是 -32,767 到 32,767 之间的一个数字。如果功能的安装级别值小于或等于产品的 INSTALLLEVEL 属性,则打开该功能: http://kb.acresso.com/selfservice/viewContent.do?externalID=Q103232
通常,您使用它来设置默认功能状态并在该功能不存在的操作系统上禁用隐藏功能不支持。但是,您可以将这些属性与在对话框的下一个按钮事件上运行的自定义操作一起使用,以强制选择至少一项功能。
是的,MSI 对话框通常没有任何意义,而且使用起来非常复杂。在某些情况下,我将序列中的单个对话框替换为常规 Windows exe 对话框,以解决整个 MSI GUI 概念中的限制。
我会考虑是否有更简单的方法来做到这一点。听起来这很紧急,所以也许您想咨询部署社区并仔细研究一些最好的部署站点:
I don't have time to run a technical test right now, but just want to point you in the direction of the INSTALLLEVEL Property. It's a rather counter-intuitive concept related to feature selections. Essentially there is an overall INSTALLLEVEL of the installation, which is a number between 1 and 32,767 and features each have an Install Level property, which is a number between -32,767 and 32,767. If a feature's Install Level value is less than or equal to the product's INSTALLLEVEL property, the feature is turned on: http://kb.acresso.com/selfservice/viewContent.do?externalID=Q103232
Generally you use this to set the default feature states and to disable hidden features on operating systems where the feature isn't supported. However, you may be able to use these properties along with a custom action run on the dialog's next button event to enforce selection of at least one of your features.
And yes, MSI dialogs in general make no sense, and they are way to complicated to work with. In some cases I have replaced a single dialog in a sequence with a regular windows exe dialog to work around limitations in the overall MSI GUI concept.
I'll have a think if there is an easier way to do this. It sounds like this is very urgent though, so perhaps you want to check with the deployment communities and peruse some of the best deployment sites: