WiX 自定义
WiX 允许用户做一些自定义操作
用户界面向导
对于安装界面,用户可以用自己的位图、图标和许可证文本替换默认的。它们的路径存储在变量中,您可以在命令行或直接在源代码中指定这些变量:
<WixVariable Id="WixUILicenseRtf" Value="images\License.rtf" />
<WixVariable Id="WixUIBannerBmp" Value="images\banner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="images\dialog.bmp" />
<WixVariable Id="WixUIExclamationIco" Value="images\exclamation.ico" />
<WixVariable Id="WixUIInfoIco" Value="images\information.ico" />
<WixVariable Id="WixUINewIco" Value="images\new.ico" />
<WixVariable Id="WixUIUpIco" Value="images\up.ico" />
其含义和细节如下:
WixUIBannerBmp 493 x 58像素,此位图将显示在除安装程序第一页之外的所有页面的顶部。
WixUIDialogBmp 493 x 312像素,此位图将显示在安装程序的第一页上。
WixUIExclamationIco 32 x 32像素,感叹号图标。
WixUIInfoIco 32 x 32像素,信息标志图标。
WixUINewIco 16 x 16像素,新文件夹图标。
WixUIUpIco 16 x 16像素,父文件夹图标。
WixUILicenseRtf 许可协议文本文件。
插入自定义页面
尽管WixUI接口库可以处理大多数常见的安装场景,但有时用户需要修改或添加一些操作。为了处理这些情况,WiX允许用户自定义对话框。
举个例子,我们在WixUI_Mondo的 “许可协议”对话框和“安装类型”对话框间加入一个注册页面。
首先,添加一个Fragment,在其中加入页面的布局描述,如下所示:
<Fragment>
<UI>
<Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="NameLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="&User Name:" />
<Control Id="NameEdit" Type="Edit" X="45" Y="85" Width="220" Height="18" Property="USERNAME" Text="{80}" />
<Control Id="OrganizationLabel" Type="Text" X="45" Y="110" Width="100" Height="15" TabSkip="no" Text="&Organization:" />
<Control Id="OrganizationEdit" Type="Edit" X="45" Y="122" Width="220" Height="18" Property="COMPANYNAME" Text="{80}" />
<Control Id="CDKeyLabel" Type="Text" X="45" Y="147" Width="50" Height="10" TabSkip="no">
<Text>CD &Key:</Text>
</Control>
<Control Id="CDKeyEdit" Type="MaskedEdit" X="45" Y="159" Width="250" Height="16" Property="PIDKEY" Text="[PIDTemplate]" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&Next">
<Publish Event="ValidateProductID" Value="0">1</Publish>
<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Please enter your customer information</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Customer Information</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
然后修改“许可协议”对话框的“下一步”按钮的链接和“安装类型”对话框的“上一步”按钮的链接。
<UI Id="MyWixUI_Mondo">
<UIRef Id="WixUI_Mondo" />
<UIRef Id="WixUI_ErrorProgressText" />
<DialogRef Id="UserRegistrationDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="UserRegistrationDlg" Order="3">LicenseAccepted = "1"</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="UserRegistrationDlg">1</Publish>
</UI>
由于UI中用到了MaskedEdit控件,需要定义相关属性
<Property Id="PIDTemplate"><![CDATA[12345<### ###>@@@@@]]></Property>
至此,一个注册页面就添加成功了。
语言
WiX支持的语言包括:ar-SA,bg-BG,ca-ES,cs-CZ,da-DK,de-DE,el-GR,en-US,es-ES,et-EE,fi-FI,fr-FR,he-IL,hi-IN,hr-HR,hu-HU,it-IT,ja-JP,kk-KZ,ko-KR,lt-LT,lv-LV,nb-NO,nl-NL,pl-PL,pt-BR,pt-PT,ro-RO,ru-RU,sk-SK,sl-SI,sr-LA,sv-SE,th-TH,tr-TR,uk-UA,zh-CN,zh-HK,zh-TW。
WiX默认生成的是英文的安装包,如果想生成其它语言,可以在 light.exe命令中加入 -cultures:xxx 参数,例如制作中文安装包:
light.exe -ext WixUIExtension -cultures:zh-CN test.wixobj
另外,如果安装程序中使用了自定义页面,使用了自定义字符串。则可以创建各语言的字符串文件,例如UserRegistrationDlg.zh-CN.wxl
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="zh-CN" Codepage="936" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="UserRegistrationDlg_Title" Overridable="yes">[ProductName] 安装</String>
<String Id="UserRegistrationDlg_UserName" Overridable="yes">用户名</String>
<String Id="UserRegistrationDlg_Organization" Overridable="yes">组织</String>
...
</WixLocalization>
同时,在wxs文件中,使用字符串改为引用的方式,比如
<Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="!(loc.UserRegistrationDlg_Title)" NoMinimize="yes">
最后,在 light.exe命令后面加上 -loc xxx.wxl 指定语言文件就可以了。
light.exe -ext WixUIExtension -cultures:zh-CN -loc UserRegistrationDlg.zh-CN.wxl test.wixobj
最新文章
- nodejs 服务端添加相应头Access-Control-Allow-Origin
- gulp.js基础入门
- git命令使用
- 趋势:Chrome为打包应用提供强大新特性
- hdu_2089(数位dp)
- OpenCV——PS滤镜,渐变映射
- C#窗体-猜数字
- 古韵之乞巧 题解 dp题
- Cookie/Session机制详解(转载)
- TStringList 常用方法与属性
- CentOS最小安装无法使用ifconfig命令
- Web jsp开发学习——实现页面跳转和传参
- 三.int , bool , str
- python-计算数据的相关性
- 第三百七十五节,Django+Xadmin打造上线标准的在线教育平台—创建课程机构app,在models.py文件生成3张表,城市表、课程机构表、讲师表
- spring boot 2.0+ 错误页面配置
- ios之开发屏幕适配和系统版本适配
- js基础之DOM中元素对象的属性方法
- DNS隧道工具iodine
- 查看SSD寿命