Каркас установщика Qt: TypeError не может прочитать имя свойства - PullRequest
0 голосов
/ 10 ноября 2019

Я попытался создать установщик, следуя инструкциям. Затем я добавил скрипт с именем "installerscript.qs" согласно примеру startmenu в каталоге Qt Installer Framework.

"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",);
    }

}

Мой пакет.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 вы можете найти все файлы моего проекта

zip-файл в этом архиве имеет целоепакет в нем

я внес изменения в свои целые пакеты, так что теперь все выглядит немного по-другому, но это то же самое

1 Ответ

0 голосов
/ 13 ноября 2019

Как отмечалось в другом комментарии, пути важны.

Честно говоря, 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] / folder.

Если это приложение Qt, вам следует использовать windeployqt.exe для каждого приложения в каждом соответствующем целевом каталоге ([имя] / данные / [имя] / [исполняемый файл]], чтобы добавить всезависимости Qt.

Наконец, чтобы сделать пакет установщика (автономная версия) с помощью следующей команды (из корневого каталога, показанного в дереве):

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