1. 安装QIF
Qt-Installer-Framework :https://download.qt.io/official_releases/qt-installer-framework/
将QIF的bin目录添加到环境变量
2. 程序准备
准备好你的程序:将程序以Release发布,新建一个文件夹到根目录,将EXE复制进去,在开始菜单找到Qt目录,打开命令行,cd到EXE目录,执行:windeployqt xxx.exe
3. 打包准备
以QIF安装目录下的examples中的tutorial为模板,将其中的文件复制到前面的文件夹,将原本程序文件剪切到packages\com.vendor.product\data
下
修改config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>CrzWallpaper</Name>
<Version>1.0.0</Version>
<Title>CrzWallpaper安装</Title>
<Publisher>三味线</Publisher>
<StartMenuDir>CrzWallpaper</StartMenuDir>
<TargetDir>@rootDir@/Program Files (x86)/CrzWallpaper</TargetDir>
</Installer>
修改packages.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>CrzWallpaper</DisplayName>
<Description>CrzWallpaper,获取必应壁纸。</Description>
<Version>1.0.0</Version>
<ReleaseDate>2018-07-10</ReleaseDate>
<Licenses>
<License name="General Public License v3" file="license.txt" />
</Licenses>
<Default>script</Default>
<Script>installscript.qs</Script>
</Package>
修改安装脚本installscript.qs:
Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
if(systemInfo.productType === "windows") {
component.addOperation("CreateShortcut","@TargetDir@/CrzWallpaper.exe", "@StartMenuDir@/CrzWallpaper.lnk");
component.addOperation("CreateShortcut","@TargetDir@/maintenancetool.exe", "@StartMenuDir@/更新或卸载.lnk");
}
} catch (e) {
console.log(e);
}
}
4. 执行打包
CMD执行 binarycreator -c config\config.xml -p packages CrzWallpaper.exe
这样安装包就完成了,其他:许可证可以自行在license.txt里填写。
参考资料:
https://blog.csdn.net/hutusoft/article/details/79060567
https://doc.qt.io/qtinstallerframework/
评论区