Nullsoft腳本安裝系統

Nullsoft腳本安裝系統

Nullsoft腳本安裝系統(NSIS)是Winamp的創建者Nullsoft支持的Microsoft Windows的腳本驅動的安裝程式創作工具。 NSIS是在免費軟體許可證的組合下發布的,主要是zlib許可證。它已成為InstallShield等商業專有產品的廣泛使用的替代品,用戶包括Amazon.com,Dropbox, Google, Ubisoft,FL Studio,BitTorrent和McAfee。

基本介紹

  • 中文名:Nullsoft腳本安裝系統
  • 外文名:Nullsoft Scriptable Install System
  • 縮寫:NSIS
歷史,概念,腳本,現代用戶界面,圖形界面,安裝程式接口,腳本示例,Hello world,簡單安裝,特點,Unicode支持,

歷史

創建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的變體是可用的。 值得注意的項目使用這個變種:
隨著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格式提供。

相關詞條

熱門詞條

聯絡我們