Wix - Conditional install of features based on radio buttons

前端 未结 2 1193
北海茫月
北海茫月 2020-12-20 01:29

I am currently learning about the WiX tool to set up MSI packages for the software applications we have where I work.

One of the things I wanted to do as part of an

相关标签:
2条回答
  • 2020-12-20 01:40

    I was having the exact same issue for days. I found many examples of condition statements online, always ending up with the same problem. After reading Michael Urman's answer, I decided to figure out what exactly he meant with "...Instead you should put Control Events on the Next (or similar) button on the dialog with the radio buttons that use AddLocal or Remove to control whether the feature gets installed."

    Here goes:

    Don't put the condition statements within features. Get rid of them. Instead, check the values of the radio buttons within the Control of a button! In your case, the Install button.

    An example:

          <Control Id="Install" Type="PushButton" X="304" Y="243" Width="56" Height="17" Default="yes" Text="Install">
            <!--Check button values here:-->
            <Publish Event="AddLocal" Value="ALL">1</Publish>
            <Publish Event="Remove" Value="feature_dir_root1">RootType = 1</Publish>
            <Publish Event="Remove" Value="feature_dir_root2">RootType = 2</Publish>
            <Publish Event="EndDialog" Value="Return" />
          </Control>
    

    I found an article that explains a bit more about all of this, along with the AddLocal Publish Event. You need that as well so don't remove it!

    So again, the value linked to the radio buttons is actually checked when the Install button is pressed. That's it basically.

    This will indeed install a feature based on the radio button selected by the user. Hope that helps!

    0 讨论(0)
  • 2020-12-20 01:50

    By the time your dialogs are shown, it's too late to set properties to influence feature conditions against INSTALLLEVEL. Instead you should put Control Events on the Next (or similar) button on the dialog with the radio buttons that use AddLocal or Remove to control whether the feature gets installed.

    0 讨论(0)
提交回复
热议问题