Using from Command Line
从命令行使用
Qt Installer Framework 4.0.0 introduces a new command line interface workflow. Most of the end user use cases can now be performed using a text based interface, either interactively, or unattended by specifying the desired options beforehand. This topic describes the basic use cases. For more information about the syntax and a description of all supported options, see Command Line Interface.
Qt Installer Framework 4.0.0引入了一个新的命令行界面工作流。现在,大多数最终用户用例都可以使用基于文本的界面来执行,无论是交互式的,还是通过预先指定所需的选项来无人值守的。本主题描述了基本用例。有关语法和所有支持选项的描述的更多信息,请参阅命令行界面。
Installing Components
安装组件
Both the installer and the maintenance tool support installation of new components from command line. The following will install the components given as an argument and their respective dependencies:
安装程序和维护工具都支持从命令行安装新组件。下面将安装作为参数给出的组件及其各自的依赖关系:
maintenancetool.exe install componentA componentB componentC
If no components are specified, the default set of components will be installed instead. This includes components with elements <Default>
or <ForcedInstallation>
set to true
. The default installation can be only done with an installer binary. The --root
option can be used to select an installation target directory:
如果未指定组件,则将安装默认组件集。这包括将元素<Default>或<ForceInstallation>设置为true的组件。默认安装只能使用安装程序二进制文件完成。--root选项可用于选择安装目标目录:
installer.exe --root "C:\Users\MyUser\MyInstallation" install
The install command can be also used for installing component aliases. If component aliases are specified, the aliased components are selected for installation:
install命令也可用于安装组件别名。如果指定了组件别名,则会选择别名组件进行安装:
maintenancetool.exe install alias1 alias2
Checking for Available Updates
检查可用更新
To print information about available component updates, run the check-updates
command with the maintenance tool:
要打印有关可用组件更新的信息,请使用维护工具运行check-updates命令:
maintenancetool.exe check-updates
Updating Components
更新组件
Running update
without arguments will update all components that have an update available. Essential and ForcedUpdate components are always updated first, same way as when launching the updater from GUI. After Essential and ForcedUpdate components are updated, the installer needs to be restarted for other updates. To update only a specific subset of installed components, they can be provided as an optional argument for update
:
运行不带参数的update
将更新所有有可用更新的组件。Essential和ForcedUpdate组件总是首先更新,与从GUI启动更新程序时的方式相同。更新Essential和ForcedUpdate组件后,需要重新启动安装程序以进行其他更新。要仅更新已安装组件的特定子集,可以将它们作为update
的可选参数提供:
maintenancetool.exe update componentA componentB
Uninstalling Components
卸载组件
The remove
command can be used to uninstall selected components. This will automatically uninstall their children and other components depending on the components about to be uninstalled:
remove命令可用于卸载选定的组件。这将根据要卸载的组件自动卸载其子组件和其他组件:
// This would also automatically uninstall componentC.subcomponent1, componentC.subcomponent2,... maintenancetool.exe remove componentC
Listing Installed Components
列出已安装的组件
To get a list and print additional information about currently installed components, run the list
command with the maintenance tool. The command also accepts an optional regular expression argument to filter the shown component list.
要获取列表并打印有关当前安装的组件的其他信息,请使用维护工具运行list命令。该命令还接受可选的正则表达式参数来筛选显示的组件列表。
maintenancetool.exe list
Searching for Available Components
搜索可用组件
The search
command can be used to search components from available repositories, or from integrated binary content in case of an offline installer. It can be used with no arguments to list all available components or with a regular expression to get a list of only components matching the pattern.
search
命令可用于从可用存储库中搜索组件,或者在脱机安装程序的情况下从集成二进制内容中搜索组件。它可以在没有参数的情况下列出所有可用组件,也可以使用正则表达式来获取仅与模式匹配的组件列表。
The --filter-packages
option can be used to specify additional filters for the search operation. For a list of usable information elements with the option, refer to Summary of Package Information File Elements.
--filter-packages选项可用于为搜索操作指定其他筛选器。有关具有该选项的可用信息元素的列表,请参阅包信息文件元素摘要。
When the value of the --type
option is set to package
, the search command will search for available components only:
当--type选项的值设置为package时,搜索命令将仅搜索可用组件:
installer.exe --type package --filter-packages "DisplayName=MyComponent, Version=1.0" search "expression"
When the --type
option is omitted, the search command will first search for matching component aliases, and if none are found, component names:
当省略--type选项时,搜索命令将首先搜索匹配的组件别名,如果没有找到,则搜索组件名称:
installer.exe search "expression"
When the value of the --type
option is set to alias
, the search command will search for available component aliases only:
当--type选项的值设置为alias时,搜索命令将仅搜索可用的组件别名:
installer.exe --type alias search "expression"
Performing Full Uninstallation
执行完全卸载
To uninstall all components and remove the program directory, including maintenance tool, run purge
command:
要卸载所有组件并删除程序目录,包括维护工具,请运行purge命令:
maintenancetool.exe purge
Creating Custom Offline Installers
创建自定义脱机安装程序
To create a personal offline installer containing a selected set of components from online repositories, use the create-offline
command. This is a useful feature for scenarios where the same installation content will be deployed multiple times or on several machines, as it saves time spent on downloading component archives and enables easily reproducible installations. The --offline-installer-name
option can be used to set a desired name for the generated offline installer.
要创建包含联机存储库中选定组件集的个人脱机安装程序,请使用create-offline命令。对于同一安装内容将被多次部署或部署在多台机器上的场景,这是一个有用的功能,因为它节省了下载组件存档的时间,并使安装易于复制。--offline-installer-name选项可用于为生成的脱机安装程序设置所需的名称。
Note that you can create offline installers only from online installers with valid repositories enabled.
请注意,只能从启用了有效存储库的联机安装程序创建脱机安装程序。
installer.exe --root "C:\TargetFolder" --offline-installer-name "MyInstaller" create-offline componentA componentB
Clearing the Local Cache
清除本地缓存
Online installers and maintenance tools created with the Qt Installer Framework cache the meta information downloaded from remote repositories to local disk. This improves loading times for subsequent metadata downloads.
使用Qt Installer Framework创建的在线安装程序和维护工具将从远程存储库下载的元信息缓存到本地磁盘。这缩短了后续元数据下载的加载时间。
The cache may grow in size over time. To clear the contents of the entire cache, use the clear-cache
command:
缓存的大小可能会随着时间的推移而增长。要清除整个缓存的内容,请使用clear-cache命令:
maintenancetool.exe clear-cache
Unattended Usage
无人值守使用
By default, the generated installers may ask for additional information during installation, which requires user attention. Unattended usage is possible by providing all information beforehand with appropriate options:
默认情况下,生成的安装程序可能会在安装过程中要求提供其他信息,这需要用户注意。通过事先提供所有信息并提供适当的选项,可以实现无人值守使用:
installer.exe --root "C:\MyInstallation" --accept-licenses --default-answer --confirm-command install componentA
In this example, --accept-licenses
is used to automatically accept all license agreements required by components to be installed. The --default-answer
option is used to answer all message queries with their default answer. Alternatively, --accept-messages
and --reject-messages
can be used to accept or reject all message queries. To provide unique answers for individual queries, for example to confirm overwriting of an existing directory, you could use --auto-answer OverwriteTargetDirectory=Yes
. Automatic answers are shown on the console output and installation log.
在这个例子中,--accept-licenses
用于自动接受要安装的组件所需的所有许可协议。--default-answer选项用于使用默认答案回答所有消息查询。或者,--accept-messages
和--reject-messages
可用于接受或拒绝所有消息查询。要为单个查询提供唯一的答案,例如确认覆盖现有目录,您可以使用--auto-answer OverwriteTargetDirectory=Yes
。自动答案显示在控制台输出和安装日志上。
By default, the installer and maintenance tool will print a summary of components to be affected by the command and then ask for permission to continue performing the action, to prevent accidental changes. For unattended usage, this can be skipped by using the --confirm-command
option.
默认情况下,安装程序和维护工具将打印受该命令影响的组件摘要,然后请求继续执行该操作的权限,以防止意外更改。对于无人值守的使用,可以使用--confirm-command
选项跳过此操作。
Specifying SettingsTutorial: Creating an Installer
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.