Windows Installer XML (WiX) 使用记录 (二) -- 使用内置界面



Wix有五个内置的界面模版:

WixUI_Advanced

WixUI_FeatureTree

WixUI_InstallDir

WixUI_Minimal

WixUI_Mondo

这里介绍一下常用的WixUI_Minimal WixUI_InstallDir WixUI_Mondo。它们基本上可以解决九成以上的问题了。

如果想要更多的信息可以到下列地址查看:

http://wixtoolset.org/documentation/manual/v3/wixui/wixui_dialog_library.html



使用内置界面之前
,需要添加引用 WixUIExtenstion.dll (AddUIExtension.png)

  1. WixUI_Minimal

    添加如下代码即可

    <UIRef Id="WixUI_Minimal"/>


    编译后出来一个极其简单的安装界面,勾选“
    Iaccept the term in the license  agreement”即可点击install  安装。

     


  2. WixUI_InstallDir

     WixUI_Minimal 相比,多了一个页面。

     

    使用方法差不多,添加如下代码: 

    <UIRef Id="WixUI_InstallDir"/>

    还需要指定一个built -in 的变量 

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />

     

  3. WixUI_Mondo

    这个模版可以让用户选择安装那些组件,如图:

     
    代码如下:

    <UIRef Id="WixUI_Mondo"/>

    这个模板有个问题,就是没有了安装路径的界面。不过它提供了为组件选择路径的功能,只需要在Feature 上指定 ConfigurableDirectory 属性。代码如下:

     

    <Feature Id="ProductFeature" Title="HelloWorldInstaller" Level="1" ConfigurableDirectory="INSTALLFOLDER">
    	<ComponentGroupRef Id="ProductComponents" />
    </Feature>
    

    效果如图:
     


    如果有好几个组件,并且希望它们都安装在同一个目录里面呢?我们可以定义多个
    Feature,然后合并到同一个Feature 下面。可以这样做:
     

    先添加两个项目,CPPConsole CSharpForm 

    然后新添加的两个项目加入安装包中

      <Fragment>
    	<ComponentGroup Id="HelloWroldComponents" Directory="INSTALLFOLDER">
          <Component Id="HelloWorld.exe" Guid="42F0F0ED-CC76-474E-95DD-71B780BDF4D2">
            <File Id="HelloWorld.exe" Source="$(var.HelloWorld.TargetDir)HelloWorld.exe" />
          </Component>
    		</ComponentGroup>
        <ComponentGroup Id="CPPConsoleComponents" Directory="INSTALLFOLDER">
          <Component Id="CPPConsole.exe" Guid="36F4C572-A95E-436D-8A4B-0F08B9AADF6D">
            <File Id="CPPConsole.exe" Source="$(var.CPPConsole.TargetDir)CPPConsole.exe" />
          </Component>
        </ComponentGroup>
        <ComponentGroup Id="CSharpFormComponents" Directory="INSTALLFOLDER">
          <Component Id="CSharpForm.exe" Guid="85A7912E-CE9D-4AE1-8AB2-C401779C6EB5">
            <File Id="CSharpForm.exe" Source="$(var.CSharpForm.TargetDir)CSharpForm.exe" />
          </Component>
        </ComponentGroup>
      </Fragment>
    


    定制 Features

    	<Feature Id="ProductFeature" Title="TestInstaller" Level="1" ConfigurableDirectory="INSTALLFOLDER" Display="expand">
          <Feature Id="HelloWorldFeature" Title="Hello World" Level="1">
            <ComponentGroupRef Id="HelloWroldComponents" />
          </Feature>
          <Feature Id="CPPConsoleFeature" Title="CPP consoloe" Level="1">
            <ComponentGroupRef Id="CPPConsoleComponents" />
          </Feature>
          <Feature Id="CSharpFormFeature" Title="C# form" Level="1">
            <ComponentGroupRef Id="CSharpFormComponents" />
          </Feature>
        </Feature>
    

     

    效果如图:

     


上述代码可以从这里获得:

https://github.com/IGabriel/WixSample/tree/Built-in-UI

 

还有两个个经常遇到的问题:

如何更换License agreement?

通常默认的license agreement 都不是你想要的,可以选择自己的 license agreement。首先准备一份license.rft 文件,里面是自己写的许可协议。接着把它放到某个地方(为了简单,放到项目的根目录)。然后添加如下代码:

就可以看到license agreement 已经替换了。

 

如何更换背景图片?

有几个built-in 的变量可以用于自定义背景图:

变量名描述规格
WixUIBannerBmp安装界面最上方的横幅493 × 58
WixUIDialogBmp整个安装包的背景图片493 × 312
WixUIInfoIco取消或者错误弹出对话框的图标32 × 32
WixUINewIco选择路径页面的“新建”按钮图标16 × 16
WixUIUpIco选择路径页面的“向上”按钮图标16 × 16

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值