需求:
- 项目编译好的Windows exe程序、dll以及其他的资源文件,在一个项目文件夹中,需要打包成一个安装程序;
- 包含多个文件和嵌套的文件夹;
- 用包含logo的图片,替换安装程序窗体的默认背景;
- 安装后,生成桌面快捷方式;
工具:
WIX Toolset - https://wixtoolset.org/
实现过程:
- 利用工具中的heat.exe将整个文件夹导出为temp.wxs文件,注意选择componentgroup -cg选项
heat.exe dir "Your_Project_Path" -cg Package -gg -sfrag -template fragment -out temp.wxs
- 将temp.wxs文件中,<fragment>内的内容全部复制到Example_Installer.wxs文件中
- 注意修改从temp.exe中复制内容的部分字段
- 根据实际情况修改Example_Installer.wxs文件,最终如下
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="7F503FBC-5FD5-4AFB-9E02-87088B2A5027" Name="Your_Product_Name" Language="1033" Version="1.0.0" Manufacturer="Developer_Name" UpgradeCode="81519c22-b44c-48c0-bf19-f045500d8a37">
<Package Id='*' Keywords='Installer' Description="Description of this Installer"
Comments='Something you want to comment' Manufacturer='Developer_Name'
InstallerVersion='100' Languages='1033' Compressed='yes' />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<