Qt Installer Framework: TypeError cannot read property name
-
Hello,
I tried creating an installer following the tutorial. I then added a script called "installerscript.qs" as per the startmenu example in the Qt Installer Framework directory.The "installerscript.qs" is as follows:
/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the FOO module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ function Component() { // default constructor } Component.prototype.createOperations = function() { // call default implementation to actually install program component.createOperations(); if (systemInfo.productType === "windows") { component.addOperation("CreateShortcut", "@TargetDir@/program.exe", "@StartMenuDir@/program.lnk", "workingDirectory=@TargetDir@", "iconPath=%TargetDir%/Logo.ico", "iconId=1", "description=Open exe"); component.addOperation("CreateDesktopShortcut", "@TargetDir@/program.exe", "@DesktopDir@/AttoView.lnk", "workingDirectory=@TargetDir@", "iconPath=%TargetDir%/Logo.ico", "iconId=1", "description=Open exe"); } }
My package.xml is as below:
<?xml version="1.0" encoding="UTF-8"?> <Package> <DisplayName>AttoView</DisplayName> <Description>Attonics Systems Spectrometer Software</Description> <Version>1.0.0-1</Version> <ReleaseDate>2019-08-19</ReleaseDate> <Licenses> <License name="End User License Agreement" file="license.txt" /> </Licenses> <Default>true</Default> <ForcedInstallation>true</ForcedInstallation> <Essential>true</Essential> <Script>installscript.qs</Script> </Package>
When I execute the installer I get the error message:
Exception while loading component script ":\\metadata\com.mycompany.program\installscript.qs": TypeError: cannot read property 'name' of null on line number: 1
This example worked when I tried it in the example directory. But gives me the above error when I modify it slightly to work with my own code.
Help please.
Thanks and regards.
-
the paths are important.
The QtInstallerFramework honestly doesn't have very good documentation and a lot of this I figured out by trial and error.
This is by no means the only way to do this. Hopefully this helps as an example. It is also worth noting that this will work on Linux/OSX as well with some slight variations.
Directory Tree:
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:
Note: The @var@ are automatically substituted, fill in the stuff in []
<?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>
From here you build your app, copy the binary to the com.[vendor].[name]/data/[name]/ folder.
If this is a Qt application you then should use the windeployqt.exe against each app in each respective the target directory ([name]/data/[name]/[executable.exe] to add in all the Qt dependencies.
Finally to make the installer package (offline version) with the following command (from the rootdir shown in the tree):
binarycreator.exe --offline-only -c "installer/config/config.xml" -p "installer/packages" "$[Name]Installer_[version].exe"
-
@Reghu_Att you know you have a answhere?
-
Thanks for the info. In my case directory structure contained dashes ("-"). That couses the same error.
<com>.<ven>-<dor>.<pro>-<duct>
removing the dashes fixes my problem. -
@Slava-Vasiliev Yeah got the same issue with dash