Nullsoft脚本安装系统(NSIS)是Winamp的创建者Nullsoft支持的Microsoft Windows的脚本驱动的安装程式创作工具。 NSIS是在免费软体许可证的组合下发布的,主要是zlib许可证。它已成为InstallShield等商业专有产品的广泛使用的替代品,用户包括Amazon.com,Dropbox, Google, Ubisoft,FL Studio,BitTorrent和McAfee。
基本介绍
- 中文名:Nullsoft脚本安装系统
- 外文名:Nullsoft Scriptable Install System
- 缩写:NSIS
历史
创建NSIS是为了分发Winamp。它基于以前的Nullsoft产品PiMP(外挂程式Mini Packager),也被称为SuperPiMP。 在版本2.0a0之后,该项目已移至SourceForge,Nullsoft以外的开发人员开始定期开展此项工作。 大约两年后,NSIS 2.0发布了。
NSIS版本1在许多方面类似于经典的Windows Installer,但它支持更多的压缩格式。 NSIS版本2具有新的简化图形用户界面,并支持LZMA压缩,多种语言和易于使用的外挂程式系统。
在2006年1月,NSIS是SourceForge本月的项目。
概念
脚本
NSIS编译器程式makensis将以下示例中的脚本编译为可执行安装程式。 脚本中的每一行都包含一个命令。
# Example scriptName "Example1"OutFile "jubaowu.exe"InstallDir "$PROGRAMFILES\Example1"Page DirectoryPage InstFilesSection SetOutPath $INSTDIR File ..\makensis.exeSectionEnd
现代用户界面
2.0版引入了一个名为Modern UI(MUI)的新的可选流线型图形用户界面。MUI有一个类似嚮导的界面。它支持欢迎页面,完成页面,语言选择对话框,组件描述区域以及比旧用户界面更多的自定义选项。
# Modern UI example script!include MUI.nshName "Example 2"OutFile "Example2.exe"!insertmacro MUI_PAGE_WELCOME!insertmacro MUI_PAGE_LICENSE "license.rtf"!insertmacro MUI_PAGE_DIRECTORY!insertmacro MUI_PAGE_COMPONENTS!insertmacro MUI_PAGE_INSTFILES!insertmacro MUI_PAGE_FINISH!insertmacro MUI_LANGUAGE "English"!insertmacro MUI_LANGUAGE "German"!insertmacro MUI_LANGUAGE "French"Section "Extract makensis" SetOutPath $INSTDIR File ..\makensis.exeSectionEnd
自NSIS版本2.30(2007年8月25日发布)以来,可以访问此UI的新版本(beta):Modern UI 2(MUI2),它是对现代UI的增强。 与旧的MUI不同,此版本基于nsDialogs而不是旧式的InstallOptions .ini档案。
从版本2.34(2007年12月24日发布)开始,MUI2已準备好进行大规模消费,并且包含在所有NSIS包中。 所有例子都已切换到它。
图形界面
只需编辑文本档案(扩展名为.nsi)即可配置NSIS项目。 但是,有几个第三方提供编辑软体:
1、EclipseNSIS是Eclipse平台的一个模组。 它允许编辑,编译和验证NSIS脚本。
2、HM NIS Edit(免费软体)编辑器,支持自定义C ++或Delphi外挂程式。
3、Venis(免费软体)编辑。
4、Visual&Installer是一个外挂程式,它将NSIS与Microsoft Visual Studio IDE集成在一起,允许在其中创建和构建NSIS项目。
安装程式接口
在过去的几年里,一些扩展或取代现代UI的项目已经开始。 诸如ExperienceUI和UltraModernUI之类的接口通过将其设定为类似于InstallShield接口来完全改变安装程式的样式。 其他接口(如installSpiderUI)旨在在视觉方面採用更简约的方法,同时保持与ASD相同的功能级别。
脚本示例
Hello world
!include "MUI.nsh"!insertmacro MUI_LANGUAGE "English"Name "Hello world!" # Name of the installer.OutFile "HelloWorld.exe" # Name of the installer's file.Function .onInit # Function that will be executed on installer's start up. MessageBox MB_OK|MB_ICONINFORMATION "Hello world!" # Show a message that says "Hello world!". Quit # Close the installer because this is a simple "Hello world!" installer.FunctionEndSection # Useless section because this is a simple "Hello world!" installer.SectionEnd
简单安装
!include "MUI.nsh"!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.!insertmacro MUI_PAGE_INSTFILES # Installing page.!insertmacro MUI_PAGE_FINISH # Finished installation page.!insertmacro MUI_LANGUAGE "English"Name "MyApp" # Name of the installer (usually the name of the application to install).OutFile "MyAppInstaller.exe" # Name of the installer's file.InstallDir "$PROGRAMFILES\MyApp" # Default installing folder ($PROGRAMFILES is Program Files folder).ShowInstDetails show # This will always show the installation details.Section "MyApp" # In this section add your files or your folders. # Add your files with "File (Name of the file)", example: "File "$DESKTOP\MyApp.exe"" ($DESKTOP is Desktop folder); or add your folders always with "File (Name of the folder)\*", always add your folders with an asterisk, example: "File /r $DESKTOP\MyApp\*" (this will add its files and (with /r its subfolders)).SectionEnd
特点
NSIS支持以下特点:
非常小的开销(34 KB);
zlib,bzip2和LZMA压缩;
基于脚本;
多种语言;
外挂程式支持;
脚本预处理器。
Unicode支持
3.0之前版本的NSIS不支持Unicode,但只是通过外挂程式将某些档案转换为不同编码的一种方式。但是,具有完全Unicode支持的NSIS的变体是可用的。 值得注意的项目使用这个变种:
- Google (Picasa)
- Apache OpenOffice
- Mozilla (Firefox, Mozilla Thunderbird)
- FileZilla
- Winamp
- Flickr
- PortableApps.com
- Second Life
- Xampp
- CherryPlayer
随着NSIS 3.0版本的发布,Unicode支持可以使用编译器指令“Unicode true”来实现。 这样就不需要进一步修改代码即可提供完整的Unicode支持,但安装程式将不能在Windows 95/98 / Me下运行。 截至2016年3.0版本发布之前,NSIS以Unicode 2.46.5 Rev 3和ANSI 2.51的PortableApps格式提供。