简体   繁体   English

NSIS安装程序基于zip?

[英]NSIS Installer based on zip?

Does anyone have a basic NSIS script example that is "installer based on zip"? 有没有人有一个基本的NSIS脚本示例是“基于zip的安装程序”? Or could tell me the command? 或者可以告诉我命令? I know NSIS has that tool built in, but I want to edit a script based on that. 我知道NSIS内置了该工具,但我想基于此编辑脚本。 NSIS only outputs an .exe of the installer based on zip. NSIS仅根据zip输出安装程序的.exe。 I would like to start from script code. 我想从脚本代码开始。

Thanks. 谢谢。

The zip2exe tool generates a simple script that it passes to makensis, most of the code is in files it includes: zip2exe工具生成一个简单的脚本,它传递给makensis,大部分代码都包含在文件中:

!define ZIP2EXE_COMPRESSOR_ZLIB
!define ZIP2EXE_INSTALLDIR "c:\foo"

!include "${NSISDIR}\Contrib\zip2exe\Base.nsh" ; You could edit this if you wanted to keep using zip2exe
!include "${NSISDIR}\Contrib\zip2exe\Classic.nsh"

!insertmacro SECTION_BEGIN
File "file1fromzip.txt"
File "file2fromzip.exe"
!insertmacro SECTION_END

you can use the following script to extract the zip files in the destination location and before you compile this script you need to download the ZipDLL.dll place it in your NSIS installation folder. 您可以使用以下脚本解压缩目标位置中的zip文件,在编译此脚本之前,需要将ZipDLL.dll下载到NSIS安装文件夹中。

OutFile "Zip.exe"
section
ZipDLL::extractall "C:\Users\raj\Desktop\envConfig.zip" "C:\Program Files (x86)\Zip"

sectionend

To build on Anders answer, a few additional things should be done in the latest version. 要在Anders答案的基础上,在最新版本中应该做一些额外的事情。 In particular ZIP2EXE_NAME and ZIP2EXE_OUTFILE should be set: 特别应设置ZIP2EXE_NAME和ZIP2EXE_OUTFILE:

!define ZIP2EXE_COMPRESSOR_ZLIB
!define ZIP2EXE_INSTALLDIR "c:\foo"
!define ZIP2EXE_NAME "My Application"
!define ZIP2EXE_OUTFILE "MyInstaller.exe"

!include "${NSISDIR}\Contrib\zip2exe\Base.nsh"
!include "${NSISDIR}\Contrib\zip2exe\Classic.nsh"

!insertmacro SECTION_BEGIN
File "file1fromzip.txt"
File "file2fromzip.exe"
!insertmacro SECTION_END

Classic.nsh can be replaced with Modern.nsh for the "Modern" UI. 对于“现代”UI,Classic.nsh可以用Modern.nsh替换。

Also note that either the files need to be enumerated in the "File" section, or if you have your files in a folder, you can include the entire contents: 另请注意,需要在“文件”部分中枚举文件,或者如果文件夹中包含文件,则可以包含整个内容:

File /r MyFolder\*.*

This will NOT create "MyFolder" inside the install target directory. 这不会在安装目标目录中创建“MyFolder”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM