WIX 安装包制作指南
WIX是开源的安装包制作工具,基于XML编译安装包,由于它提供命令行的方式编译,因此可很好的融入到开发项目的持续集成中,因此是不想用盗版也不想花钱的开发团队的最好武器。
WIX脚本
静默调用控制台程序
- 如果安装过程需要调用外部控制台程序,可屏蔽安装过程中出现的控制台窗口,如例:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
- 注意:传给"QtExecCmdLine"的值中,命令行里程序名必须用引号包围,如上例中的"sc.exe"
加入系统启动项目
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
加入桌面快捷方式
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="DesktopGTCA" Guid="aede1637-df5a-4c41-94b6-f077d03e5372">
<RegistryKey Root="HKCU" Key="Software\AAA\desktop">
<RegistryValue Value="EAFClient" Type="string" KeyPath="yes" />
</RegistryKey>
<Shortcut Id="shortcut.desk" Directory="DesktopFolder" Name="智能客户端" Target="main\main.exe" WorkingDirectory="main" Icon="EAFMain.exe" IconIndex="0" />
</Component>
</Directory>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
加入VC运行库
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
设置文件共享
需要引用UtilExtension
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
创建系统服务
- 与要运行的EXE程序的同一Component下加入
<ServiceInstall Id="service_install" Name="SERVICE_NAME" DisplayName="GTCA Server" Start="auto" ErrorControl="normal" Type="ownProcess" />
<ServiceControl Id="service_control" Name="SERVICE_NAME" Start="install" Stop="uninstall" Remove="uninstall"/>
- 要运行的EXE程序必须设置KeyPath="yes"
- 如果出现卸载时无法停止并删除服务的情况,需要为该Component重新生成GUID
补丁与升级
制作补丁(小型升级)
- 程序主版本号不变的情况下进行升级即小型升级
- 前提条件
- 前后两版本一定要ProductCode和UpgrageCode一致
- 前后两版本主版本号一致
- 编译的机器上未安装该程序的任何版本
- 步骤
- 编译得到前后两个版本msi文件
- 编制补丁的wxs文件patch.wxs
- 编制Msbuild项目文件patch.proj,其中动作顺序为
- 将前后两个版本安装到临时目录
- 编译wsx得到pcp文件
- 调用msimsp生成msp文件
安装补丁
- 直接双击运行msp文件
- 命令行
msiexec /p patch.msp REINSTALL=[Feature list] REINSTALLMODE=omus
- VB脚本
将补丁应用到MSIDIM Installer
ON ERROR RESUME NEXT
set Installer=CreateObject("WindowsInstaller.Installer")
Installer.ApplyPatch "http://server/share/patch.msp", "", 0, "REINSTALL=ALL REINSTALLMODE=omus"
set Installer=Nothing
msiexec /a [path to administrative image .msi file] /p patch.msp
部署程序集
- 一定要强签名
- 将程序集注册到GCA
- 程序修改后,一定修改版本号
- 要将程序集注册到GCA,WXS脚本如例(千万不要把Name写错,否则编译通过安装成功但注册不上)
<Component Id="AxMAVClientLib.dll" Guid="YOUR-NEW-GUID-HERE">
<File Id="AxMAVClientLib.dll" Name="AxMAVClientLib.dll" KeyPath="yes"
Assembly=".net" ProcessorArchitecture="msil" Source="AxMAVClientLib.dll" />
</Component>
参考和引用
- WIX How To http://www.dalun.com/wix/06.10.2005.htm
- WIX Q&A http://msdn.microsoft.com/chats/transcripts/windows/windows_110904a.aspx
- WIX Localization Project http://www.tramontana.co.hu/wix/loc/index.php