gpt4 book ai didi

Qt 安装程序框架 : TypeError cannot read property name

转载 作者:行者123 更新时间:2023-12-02 00:11:41 29 4
gpt4 key购买 nike

我尝试按照教程创建安装程序。然后我根据 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",);
}

}

我的 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:\system\temp\remoterepo-Q2Q7ZU\open-editor\installscript.qs": TypeError: cannot read property 'name' of null on line number: 1

当我在示例目录中尝试时,这个示例有效。但是当我稍微修改它以使用我自己的代码时,会出现上述错误。

为什么它不起作用?有什么想法吗?

我将此命令用于二进制创建器:

..\..\bin\binarycreator.exe --online-only -c config\config.xml -p packages installer.exe

您可以点击以下链接查看整个项目:https://ftp.stranica.nl/index/help/project你可以找到我项目的所有文件

the zip file in that dictory has the whole package in it

i did changes to my whole packages so now everything looks a bit different but is the same

最佳答案

正如其他评论所指出的,路径很重要。

老实说,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>

安装脚本.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 应用程序,那么您应该针对每个目标目录([name]/data/[name]/[executable.exe])中的每个应用程序使用 windeployqt.exe 以添加所有 Qt 依赖项。

最后使用以下命令(从树中显示的 rootdir)制作安装程序包(离线版本):

binarycreator.exe --offline-only -c "installer/config/config.xml" -p "installer/packages" "$[Name]Installer_[version].exe"

关于Qt 安装程序框架 : TypeError cannot read property name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58791830/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com