您的位置:首页 > 其它

Wix 安装部署(二)自定义安装界面和行为

2013-10-09 22:37 281 查看
上一篇介绍了如何联合MSBuild来自动生成打包文件和对WIX的一些初步认识,/article/4956010.html

这篇会在上篇的基础上继续探索Wix的自定义界面和行为的功能,以下都是个人的小结,不当之处欢迎指正,与君共勉!

一、安装向导

Wix提供了五种安装向导风格,

WixUI Advanced

WixUI FeatureTree

WixUI InstallDir

WixUI Minimal

WixUI Mondo

如何使用呢?需要两步,先不问为什么:

1.需要使用UIRef 元素 ,在Product中引入

<UI> <UIRef Id="WixUI_Minimal" /></UI>


2.再在安装工程上右键添加引用,引入WixUIExtension.dll ,这个dll就在你安装的wix的bin目录下面。我们再生成以下,这个时候点击安装文件,安装向导页面就出现了,先是同意许可证,再是上一步,下一步等按钮知道完成,比上一篇中的安装明显像样了些。先不着急往下走,再回头看以下

UI元素是专门用来规范安装UI的,在其中可以定义你选择的风格,设置自定义的行为等。UIRef 用来选择安装向导风格,把Id中Minmal换掉就可以了,Minmal是最简洁的。当然不能出现两个UIRef,不然WIx就凌乱了。

Advance和InstallDir 还需要其他的设置。

InstallDir 需要一个属性,让用户定义安装的地方。如下:

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="TESTFILEPRODUCTDIR" Name="Test File">
...
</Directory>
</Directory>
</Directory>
...
<Property Id="WIXUI_INSTALLDIR" Value="TESTFILEPRODUCTDIR" />
<UIRef Id="WixUI_InstallDir" />


当然要记得修改

<ComponentGroup Id="ProductComponents" Directory="TESTFILEPRODUCTDIR">


安装的时候,就会让用户选择安装位置。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="!(loc.ApplicationName)"
Language="1033" Version="1.0.0.0" Manufacturer="RJStone" UpgradeCode="3486eddf-0957-45cf-8c26-3de8bceca2b4">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />

<Feature Id="ProductFeature" Title="Setup07" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>

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

<WixVariable Id="WixUILicenseRtf" Value="lisences.rtf" />
<WixVariable Id="WixUIDialogBmp" Value="bb.jpg"/>
<WixVariable Id="WixUIBannerBmp" Value="top.jpg"/>

<Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Thank you for installing this product." />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch this Application " />

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

</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Setup07" />
</Directory>
</Directory>
</Fragment>

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<Component Id="ProductComponent">
<File Id="myapplication.exe"  Source="$(var.MyApplication.TargetPath)" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>


View Code

还是那句话,如果对你有帮助,就顶一下吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: