我尝试按照教程创建一个安装程序。然后我添加了一个名为";installerscript.qs";根据Qt安装程序框架目录中的startmenu示例。
";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",);
}
}
我的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>
当我执行安装程序时,我收到错误消息:
Exception while loading component script "D:systemtempremoterepo-Q2Q7ZUopen-editorinstallscript.qs": TypeError: cannot read property 'name' of null on line number: 1
当我在示例目录中尝试这个示例时,它就起了作用。但是,当我稍微修改它以使用自己的代码时,会出现上面的错误。
有什么想法为什么它不起作用吗?
我对二进制创建者使用此命令:
....binbinarycreator.exe --online-only -c configconfig.xml -p packages installer.exe
您可以按照以下链接查看整个项目:https://ftp.stranica.nl/index/help/project你可以找到我项目的所有文件
该dictory中的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>
config.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>
package.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>
installscript.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");
}
}
package.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>
从这里构建应用程序,将二进制文件复制到com.[vendor].[name]/data/[name]/文件夹。
如果这是一个Qt应用程序,那么你应该对每个相应目标目录中的每个应用程序使用windeployqt.exe([name]/data/[name]/[executable.exe](来添加所有Qt依赖项。
最后,使用以下命令(从树中显示的rootdir(制作安装程序包(脱机版本(:
binarycreator.exe --offline-only -c "installer/config/config.xml" -p "installer/packages" "$[Name]Installer_[version].exe"
我想我已经找到了的解决方案
open-editor
作为程序包名称错误他们想要这样的东西:
org.<vendor>.<name>.installer
因此,如果您将open-editor
重命名为org.devgroup.open_editor.installer
,您将获得一个在线和离线安装程序
编辑:
至少在windows上是这样的