【问题标题】:How can I require at least one of two optional components in WiX?我如何才能要求 WiX 中的两个可选组件中的至少一个?
【发布时间】:2009-09-02 01:29:32
【问题描述】:

我正在使用 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>

我猜我需要在序列的正确位置插入某种自定义操作,以确保选择安装其中一个,但不知道如何执行此操作,或者是否甚至对。感谢所有帮助!

【问题讨论】:

    标签: installation wix wix3


    【解决方案1】:

    我意识到这是一篇旧帖子,但这就是我使用 WIX v3.7 和 UI FeatureTree 解决这个问题的方法:

    <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">&amp;MyAppClientFeature=3 OR &amp;MyAppPrinterFeature=3</Publish>
    

    完整的 FeatureTree 覆盖代码:

    <UI Id="WixUI_FeatureTreeCustom">
        <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
        <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
        <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
    
        <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
        <Property Id="WixUI_Mode" Value="FeatureTree" />
    
        <DialogRef Id="ErrorDlg" />
        <DialogRef Id="FatalError" />
        <DialogRef Id="FilesInUse" />
        <DialogRef Id="MsiRMFilesInUse" />
        <DialogRef Id="PrepareDlg" />
        <DialogRef Id="ProgressDlg" />
        <DialogRef Id="ResumeDlg" />
        <DialogRef Id="UserExit" />
    
        <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
    
        <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
        <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
    
        <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
        <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg">LicenseAccepted = "1"</Publish>
    
        <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">Installed</Publish>
        <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" Order="2">NOT Installed</Publish>
        <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">&amp;MyAppClientFeature=3 OR &amp;MyAppPrinterFeature=3</Publish>
    
        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">NOT Installed OR WixUI_InstallMode = "Change"</Publish>
        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">Installed AND PATCH</Publish>
    
        <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
    
        <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
        <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
        <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
        <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
    </UI>
    
    <UIRef Id="WixUI_Common" />
    

    我希望这对某人有所帮助。

    【讨论】:

    • 非常好。感谢发帖。
    【解决方案2】:

    我认为您在这里真正想要做的是在 元素中为“下一步”按钮设置一个条件,以便在满足您的条件之前不启用它。比如:

    <Publish Dialog="..." Control="Next" Event="NewDialog" Value="...">OptionalPkg1Selected OR OptionaloPkg2Selected</Publish>
    

    我不知道如何根据检查的组件设置这些条件,尽管必须有一些方法可以在以后安装正确的组件...

    【讨论】:

    • 是的,我会先试试这个。否则,我不相信 WiX 有可用的“非此即彼”。您还可以有一个自定义对话框屏幕,用户必须在其中选择一个选项。
    • 我知道这是一篇古老的帖子,但谢谢杰夫。你的帖子为我指明了正确的方向。我根据您的解决方案发布了我的解决方案,作为下面的答案(至少在 WiX v3.7 中对我有用)。
    【解决方案3】:

    使用特征状态作为条件怎么样?

    类似 (&Option1=2) AND (&Option2=2)

    这是一个更好理解的链接:

    MSI Advanced Custom Actions

    【讨论】:

    • 这就是我最终要做的。我使用功能状态作为条件,将两个选项之一强制为 0 级(不安装)
    【解决方案4】:

    我现在没有时间进行技术测试,只是想向您指出 INSTALLLEVEL 属性的方向。这是一个与特征选择相关的相当违反直觉的概念。本质上,安装有一个整体 INSTALLLEVEL,它是一个介于 1 和 32,767 之间的数字,并且每个功能都有一个安装级别属性,它是一个介于 -32,767 和 32,767 之间的数字。如果某个功能的 Install Level 值小于或等于产品的 INSTALLLEVEL 属性,则启用该功能:http://kb.acresso.com/selfservice/viewContent.do?externalID=Q103232

    通常您使用它来设置默认功能状态并在不支持该功能的操作系统上禁用隐藏功能。但是,您可以将这些属性与对话框的下一个按钮事件上运行的自定义操作一起使用,以强制选择至少一项功能。

    是的,MSI 对话框通常没有意义,而且使用起来很复杂。在某些情况下,我用常规的 windows exe 对话框替换了序列中的单个对话框,以解决整体 MSI GUI 概念中的限制。

    我会考虑是否有更简单的方法来做到这一点。听起来这很紧急,所以也许您想咨询部署社区并仔细阅读一些最好的部署站点:

    【讨论】:

    • 是的,事实上我正在使用 INSTALLLEVEL 功能来设置默认组件(实际上,选择两者之一)。但是,没有什么能阻止用户将它们都关闭,这是我想要完成的。
    • 如何隐藏特征树中的特征,然后在下一个对话框中提供单选按钮样式选择?您需要对 MSI 对话框进行一些重大调整才能做到这一点,但在 Installsite 上有一篇关于如何做到这一点的文章。只是想在我挖掘之前问一下。
    猜你喜欢
    • 1970-01-01
    • 2019-05-15
    • 2020-03-08
    • 2014-09-12
    • 2013-02-24
    • 1970-01-01
    • 2010-11-21
    • 1970-01-01
    • 2021-08-06
    相关资源
    最近更新 更多