Qt程序安装包制作
//
工具下载网址
http://download.qt.io/official_releases/qt-installer-framework/3.1.1/
//
配置环境变量
右击【我的电脑】,选择【属性】->【高级系统设置】->【环境变量】进入编辑页,将 bin 路径添加到环境变量 Path 中:
//
添加帮助文档
进入 Qt Creator,选择【工具】->【选项】,然后选择左侧列表中的【帮助】->【文档】:
点击右侧的【添加】按钮,选择已安装的文档路径,选中 ifw.qch 文件,点击【OK】保存:
添加完成之后,就可以在【帮助】模式下找到 Qt Installer Framework Manual 了
//
exe文件生成依赖库命令
:windeployqt code.exe
//
IFW文件目录结构
deploy
->config //config.xml所在目录
->packages
->com.waleon.ifw
->data //可执行exe文件所在目录
->meta //package.xml/installscript.qs所在目录
//config.xml
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>MyApp</Name>
<Version>1.0.0</Version>
<Title>MyApp Installer</Title>
<Publisher>Waleon</Publisher>
<StartMenuDir>IFW Examples</StartMenuDir>
<TargetDir>@ApplicationsDir@/MyApp</TargetDir>
</Installer>
//package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>MyApp</DisplayName>
<Description>The first ifw installer.</Description>
<Version>1.0.0-1</Version>
<ReleaseDate>2019-10-12</ReleaseDate>
<Default>true</Default>
<Script>installscript.qs</Script>
</Package>
//installscript.qs
function Component()
{
// 默认构造
}
Component.prototype.createOperations = function()
{
// 调用默认实现
component.createOperations();
// 添加开始菜单
if (systemInfo.productType === "windows") {
component.addOperation("CreateShortcut",
"@TargetDir@/bin/MyApp.exe",
"@StartMenuDir@/MyApp.lnk",
"workingDirectory=@TargetDir@");
}
}
//打开CMD/PowerShell,并进入包目录 deploy 输入 :
binarycreator -c config\config.xml -p packages MyInstaller.exe -v