Qt Installer Framework:TypeError 无法读取 属性 名称

Qt Installer Framework: TypeError cannot read property name

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

你可以按照以下link查看整个项目: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>

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是这样