首先0.12以后版本原因打包方式依赖内容都不同了。 这里我找到一个最简单快捷的方式
打包工具 Inno Setup 图标更改工具ResHacker(这里下载angusj.com) 1. 从下载nwjs 2. 这里我使用的是nwjs-v0.19.5-win-x64 或sdk版 3. 在D盘建立abc目录 4. 将nwjs-v0.19.5-win-x64内文件全部copy到abc文件夹下 5. 将代码用winrar压缩,然后修改扩展名为package.nw 6. 将package.nw拷贝到abc目录下(如下图) 7. 打开InnoSetup创建一个空的脚本 脚本信息如下
; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "我的nw" ;name #define MyAppVersion "0.1" ;版本 #define MyAppPublisher "mynw" #define MyAppURL "mynw" #define MyAppExeName "nwnw.exe" ;主程序名 [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{32361EF1-C625-43D4-ADA3-1F5EE62AE3A7} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DisableProgramGroupPage=yes OutputDir=D:\abc\output ;安装包输出目录 OutputBaseFilename=setup ;//安装包名setup.exe SetupIconFile=D:\xxx\xxx.ico ;//图标 Compression=lzma SolidCompression=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] Source: "D:\abc\*"; DestDir: "{app}"; Flags: ignoreversion ;拷贝所有nwjs支持文件 Source: "D:\abc\locales\*"; DestDir: "{app}\locales"; Flags: ignoreversion [Icons] Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Registry] Root: HKCR; SubKey: isMyNw; ValueData: "URL:isMyNw Protocol"; ValueType: string; Flags: CreateValueIfDoesntExist UninsDeleteKey; Root: HKCR; SubKey: isMyNw; ValueName: "URL Protocol"; Flags: CreateValueIfDoesntExist; ValueType: string; Root: HKCR; SubKey: isMyNw\DefaultIcon; ValueData: "{app}\{#MyAppExeName},1"; Flags: CreateValueIfDoesntExist; ValueType: string; Root: HKCR; SubKey: isMyNw\shell\open\command; ValueData: "{app}\{#MyAppExeName} %1"; Flags: CreateValueIfDoesntExist; ValueType: string;点击运行则开始打包,最后到output找到安装包即可
如遇到图标没有写入的问题 使用文章开头说到的图标替换工具即可