Mat*_*990 2 qt qtscript qt5 qt-installer
我尝试按照教程创建一个安装程序。然后,我根据 Qt Installer Framework 目录中的开始菜单示例添加了一个名为“installerscript.qs”的脚本。
“installscript.qs”如下:
/****************************************************************************
**
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
**
**
** open-editor to use.
** Copyright (C) 2018 os_sys-devlopment-group
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
** view the full license at https://www.stranica.nl/open-editor/license.txt
**
** $QT_END_LICENSE$
**
****************************************************************************/
function Component()
{
// default constructor
}
Component.prototype.createOperations = function()
{
component.createOperations();
if (systemInfo.productType === "windows") {
component.addOperation("CreateShortcut", "@TargetDir@/customtexteditor.exe", "@StartMenuDir@/open-editor.lnk",
"workingDirectory=@TargetDir@","iconPath=%TargetDir%/Logo.ico");
component.addOperation("CreateDesktopShortcut", "@TargetDir@/customtexteditor.exe", "@DesktopDir@/open-editor.lnk",
"workingDirectory=@TargetDir@", "iconPath=%TargetDir%/Logo.ico",);
}
}
Run Code Online (Sandbox Code Playgroud)
我的package.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>open-editor</DisplayName>
<Description>open-editor</Description>
<Version>1.0.2</Version>
<ReleaseDate>2019-11-10</ReleaseDate>
<Default>true</Default>
<Name>open-editor</Name>
<Licenses>
<License name="End User License Agreement" file="license.txt" />
</Licenses>
<ForcedInstallation>true</ForcedInstallation>
<Script>installscript.qs</Script>
</Package>
Run Code Online (Sandbox Code Playgroud)
当我执行安装程序时,我收到错误消息:
Exception while loading component script "D:\system\temp\remoterepo-Q2Q7ZU\open-editor\installscript.qs": TypeError: cannot read property 'name' of null on line number: 1
Run Code Online (Sandbox Code Playgroud)
当我在示例目录中尝试时,这个示例有效。但是当我稍微修改它以使用我自己的代码时,就会出现上述错误。
任何想法为什么它不起作用?
我使用这个命令来创建二进制文件:
..\..\bin\binarycreator.exe --online-only -c config\config.xml -p packages installer.exe
Run Code Online (Sandbox Code Playgroud)
您可以点击以下链接查看整个项目:https://ftp.stranica.nl/index/help/project您可以找到我项目的所有文件
该目录中的 zip 文件包含整个包
我对整个包进行了更改,所以现在一切看起来有点不同,但都是一样的
正如其他评论指出的那样,路径很重要。
老实说,QtInstallerFramework 没有很好的文档,其中很多内容是我通过反复试验发现的。
这绝不是唯一的方法。希望这作为一个例子有帮助。还值得注意的是,这也适用于 Linux/OSX,但有一些细微的变化。
目录树:
rootdir
installer
config
config.xml <#1 below>
packages
com.<vendor>.installer
meta
package.xml <#2 below>
com.<vendor>.<name> [This can be 1-N of these]
meta
installscript.qs <#3 below>
package.xml <#4 below>
data
<name>
<executable and dependencies here>
Run Code Online (Sandbox Code Playgroud)
配置.xml#1:
注:@var@会自动替换,[]中的内容填入
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>[Name]</Name>
<Version>[Version]</Version>
<Title>[Application Title]</Title>
<Publisher>[Publisher]</Publisher>
<StartMenuDir>[VendorName]/[Name] [Version]</StartMenuDir>
<TargetDir>@ApplicationsDir@/[Publisher]/[Name] @Version@</TargetDir>
<ProductUrl>[yoururlhere.com]</ProductUrl>
</Installer>
Run Code Online (Sandbox Code Playgroud)
包.xml#2:
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>Installer</DisplayName>
<Description>[Publisher] Software Installer</Description>
<Version>[1.0.0]</Version>
<ReleaseDate>[2019-11-13]</ReleaseDate>
<Name>com.[Vendor].installer</Name>
<Virtual>true</Virtual>
<UpdateText>This changed compared to the last release</UpdateText>
</Package>
Run Code Online (Sandbox Code Playgroud)
安装脚本.qs #3:
function Component()
{
// default constructor
}
Component.prototype.createOperations = function()
{
// This actually installs the files
component.createOperations();
if (systemInfo.productType == "windows") {
// Start menu shortcut
component.addOperation("CreateShortcut",
"@TargetDir@/[Name]/[Executable.exe]",
"@StartMenuDir@/[Name].lnk",
"workingDirectory=@TargetDir@/[Name]",
"iconPath=@TargetDir@/[Name]/[Name].ico");
// Desktop Shortcut
component.addOperation("CreateShortcut",
"@TargetDir@/[Name]/[Executable.exe]",
"@DesktopDir@/[Name] @Version@.lnk",
"workingDirectory=@TargetDir@/[Name]",
"iconPath=@TargetDir@/[Name]/[Name].ico");
}
}
Run Code Online (Sandbox Code Playgroud)
包.xml#4:
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>[Name]</DisplayName>
<Description>[Some description]</Description>
<Version>[Version]</Version>
<ReleaseDate>[Date]</ReleaseDate>
<Name>com.[vendor].[name]</Name>
<Script>installscript.qs</Script>
<Default>false</Default>
<ForcedInstallation>true</ForcedInstallation>
</Package>
Run Code Online (Sandbox Code Playgroud)
从这里构建您的应用程序,将二进制文件复制到 com.[vendor].[name]/data/[name]/ 文件夹。
如果这是一个 Qt 应用程序,那么您应该对每个目标目录([名称]/data/[名称]/[executable.exe] 中的每个应用程序使用 Windeployqt.exe 以添加所有 Qt 依赖项。
最后使用以下命令制作安装程序包(离线版本)(来自树中显示的 rootdir):
binarycreator.exe --offline-only -c "installer/config/config.xml" -p "installer/packages" "$[Name]Installer_[version].exe"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1442 次 |
| 最近记录: |