This article can be seen as an extension of the previous one, "nsNiuniuSkin Installer Configuration Guide." It builds upon the Python command-line interface and adds support for a visual configuration interface with explanations!
nsNiuniuSkin has always positioned itself as a solution for quickly integrating into the automated packaging process, focusing on providing a good integration interface for users. With the formal introduction of our Python command-line script and the integration of various installer capabilities, this part of the work has been successfully completed.
However, among our users, there are still many students, individual developers, web front-end developers (Electron), backend developers, etc. The proportion of users who specialize in Windows desktop software development is relatively small. These users, due to their work environment, are relatively unfamiliar with the configuration of NSIS installer creation, often finding it challenging to understand how to configure it even after reading our instructions.
Now is the time to consider how to help more users get started more quickly.
In order to ensure that all users have a clear understanding of the configuration process of nsNiuniuSkin installer solution, we have developed a visual configuration wizard. This wizard presents the configuration parameters in a visual interface, helping users find the corresponding parameters to modify among many configuration options. Using the nsNiuniuSkin installer creation visual configuration wizard, you can quickly generate installer packaging scripts and compile the installer. Moreover, the configuration process helps users better understand the significance of our command-line scripts, facilitating quick integration into automated compilation and packaging workflows!
As seen above, the entire wizard interface is divided into three areas:
Next, we will explain each of these three parts of the configuration.
The nsNiuniuSkin visual wizard supports the simultaneous management of multiple configurations. For example, one configuration could be for packaging a template with a beach style, and another could be for packaging a template with a mountain style. You can also copy, rename, delete, and perform other operations on existing templates.
The various parameters of control configuration are not intended to be directly passed to NSIS. Instead, they are used in our Python packaging script for actual pre-packaging logical control, such as code signing, compiling and packaging Electron, etc. Specifying the correct parameters allows accurate control of the behavior of the entire packaging process.
Control Name | Purpose | Note |
---|---|---|
Project Name | The directory name where your purchased template resources are stored, e.g., leeqia_simple | Clicking "Load Default NSI Configuration" at this point will read the default configuration from soft_setup.nsi |
Packaging Mode | The type of installer package and compression method to use |
7z: Compresses into app.7z before packaging and then proceeds with packaging nozip: Directly uses nsis for packaging online: Creates an online installer |
Sign or Not | Whether to sign the uninstall program and installer program during the packaging process | If signing is selected, you also need to configure the signing certificate under the Sign directory |
Local File Directory Name | The directory name under the packaging directory to store files to be packaged, default is FilesToInstall | It is recommended not to modify this value |
Source Directory | This is an optional configuration. If configured, all files in this path will be copied to FilesToInstall before packaging | This configuration is ineffective if Electron packaging is enabled |
Uninstall File Name | The name of the uninstall program in the installer package | Default is uninst.exe |
Package Electron or Not | Indicates whether to package the Electron program |
If yes, npm build run command will be invoked before packaging to generate unpacked files, and these files will be copied to FilesToInstall Additionally, we will copy the software name, version number, guid, and other fields from the package.json in the Electron project directory |
Electron Project Path | Specifies the location of the Electron project when Electron packaging is enabled | Path to the electron-builder packaging configuration file package.json |
Generate latest.yml or Not | Whether to generate latest.yml after packaging for electron-updater | latest.yml includes the installer file name, version number, and sha512 value of the installer package |
It's worth noting that several parameters are associated with whether Electron packaging is enabled. The overall principle is:
Each custom macro has a default value defined in the soft_setup.nsi file. If the corresponding parameters are configured on the interface, the default values in soft_setup.nsi will not be used, achieving the purpose of personalized configuration of installer parameters.
Control Name | Purpose | Note |
---|---|---|
Product Name | The product name of the product you want to package, e.g., Leiqia Screenshot Control | |
English Product Name | The English product name of the product you want to package, e.g., Leeqia ScreenCapture | Used in multilingual scenarios. If you have added new languages, please add them to soft_setup.nsi |
Installer Package Name | The filename of the final installer package, e.g., Watercurtain_Setup_v2.5.0.exe | If Electron packaging is enabled, it will be generated based on the name value configured in package.json |
Product Version | The version number of the product, e.g., 2.5.0.0 | If Electron packaging is enabled, it will be used based on the version value configured in package.json |
Main Program Name | The name of the main program exe, e.g., NiuniuScreenshot.exe | If Electron packaging is enabled, it will be generated based on the {name}.exe value configured in package.json |
Extension Path Name | The folder name to be appended during installation, e.g., Leeqia_Capture | The extension folder is used to ensure that all installed files are in our specific directory |
Software Install Registry Identifier |
The location where installation information is saved in the registry, e.g., [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Leeqia_Capture] "InstPath"="C:\Program Files (x86)\Leeqia_Capture" |
If Electron packaging is enabled, it will be used based on the guid in package.json |
Install Path Registry Key |
The location where the installation path is saved in the registry, e.g., [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Leeqia_Capture] "InstPath"="C:\Program Files (x86)\Leeqia_Capture" |
If Electron packaging is enabled, use InstallLocation |
Default Installation Path | Default installation path when the installer is opened for the first time, e.g., $PROGRAMFILES32${INSTALL_APPEND_PATH} | Needs to be determined based on whether it is installed for all users and the execution permissions of the installer |
Online Package Download Base URL | The base path for downloading data packages when creating an online installer, e.g., http://www.ggniu.cn/test_online_install/ | Place the generated app.7z and config.ini in the corresponding directory on the server |
Copyright Information | Information displayed in the installer package details, e.g., Leeqia Copyright (c) 2020 | |
Publisher Information | Information displayed in the installer package details, e.g., Leeqia | |
Default Create Shortcut | Whether the "Create Shortcut" checkbox on the interface is automatically selected | Adjustable during installation |
Default Add to Startup | Whether the "Add to Startup" checkbox on the interface is automatically selected | Adjustable during installation |
Installer Package Execution Permission | Whether to start the installer package with administrator privileges: admin/user |
If administrator privileges are selected, it is recommended to install for all users, and choose a default path independent of a specific user |
Install for Current User or All Users | Whether to install for the current user or all users: all/current |
If administrator privileges are selected, it is recommended to install for all users, and choose a default path independent of a specific user |
In custom configuration macros, several parameters are interrelated, such as default installation location, installer package execution permissions, and whether to install for all users:
After setting the project name (assuming the name is leeqia_simple), click this button to read the macro definitions from .\SetupFiles\leeqia_simple\soft_setup.nsi and display them on the interface:
# ====================== Custom Macros: Product Information ===============================
!define /ifndef PRODUCT_NAME "利洽科技截图控件" #Product Name
!define /ifndef PRODUCT_NAME_EN "Leeqia ScreenCapture" #English Product Name
!define /ifndef PRODUCT_PATHNAME "Liqia_Capture" #Key used for installation and uninstallation, same as the guid in Electron
!define /ifndef INSTALL_APPEND_PATH "Liqia_Capture" #Name appended to the installation path
!define /ifndef INSTALL_DEFALT_SETUPPATH "$PROGRAMFILES32\${INSTALL_APPEND_PATH}" #Default generated installation path
!define /ifndef EXE_NAME "NiuniuScreenshot.exe" #Main program EXE filename
!define /ifndef PRODUCT_VERSION "2.5.0.0" #Version number
!define /ifndef PRODUCT_PUBLISHER "Leeqia" #Publisher
!define /ifndef PRODUCT_LEGAL "Liqia Copyright (c) 2020" #Copyright information
!define /ifndef INSTALL_MODE_ALL_USERS "all" # 'all' or 'current', whether to install for all users, affects registry, shortcuts, start menu, etc.
!define /ifndef INSTALL_EXECUTION_LEVEL "admin" # If INSTALL_MODE_ALL_USERS is 'current', synchronize this to 'user' (RequestExecutionLevel none|user|highest|admin)
!define /ifndef INSTALL_OUTPUT_NAME "Test_PC_Setup_v2.5.0.exe" #Default installer package name, controlled by passing parameters in bat
!define /ifndef INSTALL_LOCATION_KEY "InstPath" #Key value for the installation location in the default registry
# ====================== The following macros control specific behaviors ==============================
!define /ifndef INSTALL_DEFAULT_AUTORUN 0 #Default auto-run on startup
!define /ifndef INSTALL_DEFAULT_SHOTCUT 0 #Default add shortcut
!define /ifndef TEST_SLEEP 1 #Switch for testing delay during installation, change to 0 for actual use
!define /ifndef INSTALL_DOWNLOAD_BASEURL "http://www.ggniu.cn/test_online_install/" #Base URL for downloading data packages during online installation
# ====================== The specific macro definitions above can be predefined in the pre_define.nsh file, and can be arbitrarily specified as other values ==============================
Button Name | Button Purpose |
---|---|
Save Configuration and Script | Save the current configuration name and content to the corresponding json file; simultaneously generate a bat file containing the generated packaging command line parameters |
Generate Installer Package | Save configuration and script, then call the generated bat script to generate the installer package |
Run Installer Package | Run the packaged installer package based on the current configuration name and content |
Open UI Debugger |
Open through the browser: http://ggniu.com/articles/nsniuniuskin_designer.html At this point, the path of the skin directory under the corresponding project name will be copied to the clipboard by default, making it easy to paste and use on the page |
The following workflow demonstrates how to create a new configuration, copy another configuration from it, and then package it:
Run gui_package.bat to open the configuration guide
Enter the configuration name: leeqia_simple_gui, click New Configuration
In the project name, enter leeqia_simple, click Load Default Configuration from NSI. This step will read the default values of each macro from the soft_setup.nsi file in the leeqia_simple template directory, helping you initialize the configuration. After this, you can perform various modifications on the interface as needed
Click Save Configuration and Script. At this point, based on the project name on the interface and the selected packaging mode, the generate_leeqia_simple_nozip.bat script will be generated. The script contains command line parameters on how to call package.py, the content is as follows:
chcp 65001
python package.py --project_name="leeqia_simple" --package_mode=2 --need_sign=False --build_for_electron=False --generate_latest_file=False --files_toinstall_name="FilesToInstall" --uninst_file_name="uninst.exe" --PRODUCT_NAME="Leeqia Screenshot Control" --PRODUCT_NAME_EN="Leeqia ScreenCapture" --INSTALL_OUTPUT_NAME="Test_PC_Setup_v2.5.0.exe" --PRODUCT_VERSION="2.5.0.0" --EXE_NAME="NiuniuScreenshot.exe" --INSTALL_LOCATION_KEY="InstPath" --INSTALL_APPEND_PATH="Liqia_Capture" --PRODUCT_PATHNAME="Liqia_Capture" --INSTALL_DEFALT_SETUPPATH="$PROGRAMFILES32\${INSTALL_APPEND_PATH}" --INSTALL_DEFAULT_SHOTCUT=1 --INSTALL_DEFAULT_AUTORUN=0 --INSTALL_EXECUTION_LEVEL="admin" --INSTALL_MODE_ALL_USERS="all" --INSTALL_DOWNLOAD_BASEURL="http://www.ggniu.cn/test_online_install/" --PRODUCT_LEGAL="Liqia Copyright (c) 2020" --PRODUCT_PUBLISHER="Leeqia" --TEST_SLEEP=0
chcp 936
Run the generate_leeqia_simple_nozip.bat script to directly generate the corresponding installation package. At the same time, with the command line parameters of this pycakge.py, you can integrate it directly into your automated packaging process, just need to further dynamically pass in certain parameters (such as the version number passed in each time during packaging).
Enter leeqia_mountain_gui in the configuration name, click Copy Configuration. At this point, a new configuration item is copied from leeqia_simple_gui, and you need to modify the project name to leeqia_mountain (of course, you can also modify other parameters). Click Save to generate the script for packaging the mountain template
Click Generate Installer Package, wait for a while, and you can complete the packaging of the mountain template
The above process is fully visualized, without any development foundation, and I believe it is helpful to all users! The following is a gif screen recording of the actual operation:
In the configuration management, one configuration corresponds to one json configuration file, which is used to record various configuration parameters in this configuration. For example, leeqia_simple_gui corresponds to leeqia_simple_gui.json under the packaging directory; the visual configuration guide will traverse the json files under the packaging script directory and load them into the interface for display and control.
Each configuration on the configuration guide is ultimately converted into a command line parameter of Python and saved in the generated bat file. For the consideration that users may need to extend the visual guide by themselves later, we did not use C++ to implement this guide, but used a Python script for implementation. The code is open, relying on tkinter for visual display. You can extend this configuration guide by yourself later and add more features you want!
The visual guide is not only an auxiliary packaging tool for nsNiuniuSkin but also a good demo of developing cross-platform desktop programs using Python. If you can be helped in developing some simple tools in the future after looking at all the code of our visual configuration guide, that will be our greatest honor!
Note:
To run this visual guide, you need to install python3 on your computer
To run this visual guide, you need to install the tkinter module on your computer. Installation method: npm install tk in the command line
Configuring the tkinter interface manually is too troublesome, so we used https://www.pytk.net/tkinter-helper/ to configure the interface
All the parameters in nsNiuniuSkin's visual configuration guide correspond one-to-one to the command line parameters in package.py. I hope that with it, your configuration efficiency and accuracy can be improved.
During the installation package installation process, a beautiful UI often makes customers more impressed with the installed product and better reflects the service provider's focus and care on user experience! I hope our efforts can make package creation a bit easier and more enjoyable!
May there be no difficult installation packages in the world!