0
点赞
收藏
分享

微信扫一扫

【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)


文章目录

  • ​​1、NSIS​​
  • ​​1.1 软件简介​​
  • ​​1.2 下载安装​​
  • ​​1.3 代码示例​​
  • ​​2、Inno Setup​​
  • ​​2.1 软件简介​​
  • ​​2.2 下载安装​​
  • ​​2.3 代码示例​​
  • ​​结语​​

1、NSIS

官网地址:
​​​https://nsis.sourceforge.io/Main_Page​​

最新版本:NSIS 3.08,September 25, 2021

【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_innosetup

NSIS(Nullsoft Scriptable Install System)是用于创建 Windows安装程序的专业开源系统。它被设计为尽可能小而灵活,因此非常适合互联网分发。
NSIS (Nullsoft Scriptable Install System) 是 Windows 下的一个安装程序创建工具,它允许程序员来创建这样的安装程序。 它发布于一个开源的协议并且对于 任何使用者来说都是完全免费的。

【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_nsis_02

1.1 软件简介

  • NSIS 创建的安装程序能够安装、卸载、设置系统设置、解压文件等等。
  • 因为它基于脚本文件,你可以完全的控制安装程序的每一部分。 脚本语言支持变量、函数、字串操作,就像一个普通的程序语言一样 - 但是设计来创建安装程序。
  • 即使有那么多的特性, NSIS 仍然是最小的安装程序系统。在默认选项下,它仅增加了 34 KB 的开销。
  • 你可以在(ZLib, BZip2, LZMA)这三种完整的压缩方法中选择其一。新的 LZMA 压缩具有比其它通用压缩方法更好的效果。而且你不需要大块的外壳释放文档模块或其它的应用程序。该压缩方式已经包含在那 34 KB 的额外开销里。
  • 不像其它的安装系统仅能基于文件列表和注册表操作来创建安装程序,NSIS 有一个强大的脚本语言。该脚本语言设计来专门制作安装程序并有可以帮助你执行任何安装任务的命令。你可以很容易的添加自定义逻辑和处理不同的升级、版本检测等。
  • NSIS 可以由能和安装程序对话的插件来扩展。他们可以由 C, C++, Delphi 或其他语言并且可以用来执行安装任务或扩展安装程序界面。使用这些插件你只需要一行代码。
  • NSIS 具有体积小、速度快和高效率的特点。当其它安装程序动辄需要几百 KB 或好几 MB 的安装程序数据,而一个具有完整功能的 NSIS 安装程序仅占用了 34 KB 的额外开销。

1.2 下载安装

​​https://nsis.sourceforge.io/Download​​

【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_innosetup_03


【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_innosetup_04

1.3 代码示例

  • 脚本示例:

; example1.nsi
;
; This script is perhaps one of the simplest NSIs you can make. All of the
; optional settings are left to their default settings. The installer simply
; prompts the user asking them where to install, and drops a copy of example1.nsi
; there.
;
; example2.nsi expands on this by adding a uninstaller and start menu shortcuts.

;--------------------------------

; The name of the installer
Name "Example1"

; The file to write
OutFile "example1.exe"

; Request application privileges for Windows Vista
RequestExecutionLevel user

; Build Unicode installer
Unicode True

; The default installation directory
InstallDir $DESKTOP\Example1

;--------------------------------

; Pages

Page directory
Page instfiles

;--------------------------------

; The stuff to install
Section "" ;No components page, name is not important

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File example1.nsi

SectionEnd

2、Inno Setup

官网地址:
​​​https://jrsoftware.org/isinfo.php​​​​https://github.com/jrsoftware/issrc​​

最新版本:innosetup-6.2.1.exe,2022-04-14

【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_install_05

2.1 软件简介

Inno Setup 是Jordan Russell 和 Martijn Laan 为 Windows 程序提供的免费安装程序。Inno Setup 于 1997 年首次推出。

  • 支持自 2006 年以来的每个 Windows 版本,包括:Windows 11、Windows 10、Windows 10 on ARM、Windows Server 2019、Windows Server 2016、Windows 8.1、Windows 8、Windows Server 2012、Windows 7、Windows Server 2008 R2、Windows Server 2008和 Windows Vista。(不需要服务包。)
  • 广泛支持在 64 位版本的 Windows 上安装64 位应用程序。x64、ARM64 和 Itanium 架构均受支持。
  • 文件安装:包括对“deflate”、bzip2 和7-Zip LZMA/LZMA2 文件压缩的集成支持。安装程序能够比较文件版本信息、替换正在使用的文件、使用共享文件计数、注册 DLL/OCX 和类型库以及安装字体。
  • 用于高级运行时安装和卸载定制的集成 Pascal 脚本引擎选项。
  • 是的,它可以完全免费使用,即使在部署商业应用程序时也是如此。

2.2 下载安装

  • (1)版本6+
    ​​https://jrsoftware.org/isdlold.php#6​​
  • 【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_innosetup_06


  • 【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_打包_07


  • 【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_install_08

  • (2)版本5+
    ​​https://files.jrsoftware.org/is/5/​​
  • 【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_安装_09


  • 【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_install_10


  • 【夏虫语冰】开源软件安装包制作工具(NSIS,Inno Setup)_install_11

2.3 代码示例

  • 脚本示例:

; -- Example1.iss --
; Demonstrates copying 3 files and creating an icon.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

结语

​如果您觉得该方法或代码有一点点用处,可以给作者点个赞​

​​​如果您感觉方法或代码不咋地​​​//(ㄒoㄒ)//​​,就在评论处留言,作者继续改进;​​​o_O???
​​​如果您需要相关功能的代码定制化开发,可以留言私信作者;​​​(✿◡‿◡)
​​​感谢各位童鞋们的支持!​​( ´ ▽´ )ノ ( ´ ▽´)っ!!!

举报

相关推荐

0 条评论