使用 Wix 安装结束时添加多个复选框 [英] Add more than one checkbox when install with Wix is over

查看:35
本文介绍了使用 Wix 安装结束时添加多个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的 C# 应用程序的设置.在设置结束时,我添加了一个建议启动应用程序的复选框.它运作良好.但我无法添加建议启动可选安装程序的第二个复选框.

I have an setup for my C# application. At the end of setup I added a checkbox proposing to launch application. It works good. But i'm unable to add a second checkbox proposing to launch an optional installer.

这是我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "myCompagny"?>
<?define product = "myProduct"?>
<?define version = "!(bind.FileVersion.MyProject.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*"
           Name="$(var.product)"
           Language="1033"
           Version="$(var.version)"
           Manufacturer="$(var.compagny)"
           UpgradeCode="PUT-GUID-HERE">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>
    <Icon Id="icone.ico" SourceFile="$(var.MyProject.ProjectDir)\Images\icone-VR.ico"/>
    <Property Id="ARPPRODUCTICON" Value="icon.ico"/>
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
    <Media Id="1" Cabinet="MyProject.cab" EmbedCab="yes"/>

    <Feature Id="ProductFeature" Title="$(var.product)" Level="1">
      <ComponentGroupRef Id="ProductComponents"/>
      <ComponentRef Id ="ApplicationShortcut"/>
      <ComponentRef Id ="ApplicationShortcutDesk"/>
    </Feature>

    <WixVariable Id="WixUILicenseRtf"
                 Value="..\license.rtf"/>
    <WixVariable Id="WixUIBannerBmp"
                 Value=".\Resources\WixUIBannerBmp.bmp"/>
    <WixVariable Id="WixUIDialogBmp"
                 Value=".\Resources\WixUIDialogBmp.bmp"/>

    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.product)" />
    <Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Warning. If you don't have optionnal package, consider to install it."/>

    <Property Id="WixShellExecTarget" Value="[#MyProject.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

    <UI>
      <UIRef Id="WixUI_Minimal"/>
      <Publish Dialog="ExitDialog"
               Control="Finish" 
               Event="DoAction" 
               Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>
  </Product>

  [...]
 </Wix>

如何添加另一个 CheckBox 来启动 ./Resources.myOptionalPackage.exe ?

How can I add another CheckBox to launch ./Resources.myOptionalPackage.exe ?

如果我不能添加另一个复选框,我可以添加一个用于安装该功能的新对话框页面吗?

If I can't add another checkbox, can I add a new dialog page used to install the feature ?

推荐答案

您必须使用自定义对话框创建自己编辑的 UI.

You must create own edited UI with custom dialog.

1.首先去官方GIT仓库并复制文件 WixUI_Minimal.wxsExitDialog.wxs ,或复制整个存储库并在本地查找文件.为您的项目/解决方案创建自己的此文件副本,并将它们重命名为例如 WixUI_Custom.wxsMyExitDialog.wxs .

1.First go to official GIT repository and copy files WixUI_Minimal.wxs and ExitDialog.wxs , or copy whole repository and find files locally. Create own copies of this files to you project/Solution and rename them for example to WixUI_Custom.wxs and MyExitDialog.wxs .

也替换新文件的内容,为WixUI_Minimal.wxs替换

Replace content of new files too, for WixUI_Minimal.wxs replace

,

ExitDialog.wxs 替换

和两者

<Show Dialog="ExitDialog" OnExit="success" Overridable="yes"/><Show Dialog="MyExitDialog" OnExit="success" Overridable=是"/>

2. 将产品中的 更改为

2.Change <UIRef Id="WixUI_Minimal"/> in your Product to <UIRef Id="WixUI_Custom"/>

3.现在您的安装程序应该像以前一样以完全相同的用户界面打开,但来自您的类

3.Now you installer should open with exact UI as before, but from your classes

4.打开WixUI_Custom并修改

因此 UI 将打开我们的新对话框.

so UI will open our new Dialog.

5.Open MyExitDialog.wxs 并添加新的控制块,因为它已经存在

5.Open MyExitDialog.wxs and add new Control block, as it is already present

<Control Id="OptionalCheckBox" Type="CheckBox" X="135" Y="190" Width="220" Height="40" Hidden="yes" Property="WIXUI_EXITDIALOGOPTIONALCHECKBOX" CheckBoxValue="1" Text="[WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT]">
  <Condition Action="show">
    WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT Installed
  </Condition>
</Control>

将标识符 Id 更改为任何内容,X,Y 用于对话框中的新位置,Property 用于新属性,其中将存储复选框值和新属性的 Text,其中将存储显示的文本.也将 Text 属性置于 Condition 中,因此显示将取决于文本属性集,如现有复选框中一样.

Change identificator Id to anything, X,Y for new position in dialog, Property for new property, in which will be checkbox value stored and Text for new property, in which will be displayed text stored. Place Text property to Condition too, so display will depend on text property set, as in existing checkbox.

<Control Id="SecondCheckBox" Type="CheckBox" X="135" Y="220" Width="220" Height="40" Hidden="yes" Property="WIXUI_SECONDCHECKBOXVALUE" CheckBoxValue="1" Text="[WIXUI_EXITDIALOGSECONDCHECKBOXTEXT]">
  <Condition Action="show">
    WIXUI_EXITDIALOGSECONDCHECKBOXTEXT AND NOT Installed
  </Condition>
</Control>

6.现在您可以使用新的 Checkbox 执行与使用新控件中定义的新属性相同的操作.

6.Now you can do the same things with new Checkbox as with existing using new properties defined in new Control.

这篇关于使用 Wix 安装结束时添加多个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆