nwjs 0.19打包exe

首先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找到安裝包即可

如遇到圖標沒有寫入的問題
使用文章開頭說到的圖標替換工具即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章