feat(打包): 添加Windows单文件打包脚本和工具安装脚本
添加install_build_tools.bat用于自动安装构建工具 添加package_windows_single_exe.ps1用于打包Flutter应用为单文件 改进inno_setup.sas增加卸载清理逻辑和进程终止功能
This commit is contained in:
@@ -49,7 +49,7 @@ CloseApplications=force
|
||||
{% endfor %}
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: {% if CREATE_DESKTOP_ICON != true %}unchecked{% else %}checkedonce{% endif %}
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkedonce
|
||||
Name: "launchAtStartup"; Description: "{cm:AutoStartProgram,{{DISPLAY_NAME}}}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: {% if LAUNCH_AT_STARTUP != true %}unchecked{% else %}checkedonce{% endif %}
|
||||
[Files]
|
||||
Source: "{{SOURCE_DIR}}\\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
@@ -62,14 +62,82 @@ Name: "{userstartup}\\{{DISPLAY_NAME}}"; Filename: "{app}\\{{EXECUTABLE_NAME}}";
|
||||
[Run]
|
||||
Filename: "{app}\\{{EXECUTABLE_NAME}}"; Description: "{cm:LaunchProgram,{{DISPLAY_NAME}}}"; Flags: {% if PRIVILEGES_REQUIRED == 'admin' %}runascurrentuser{% endif %} nowait postinstall skipifsilent
|
||||
|
||||
[UninstallDelete]
|
||||
Type: filesandordirs; Name: "{app}"
|
||||
Type: filesandordirs; Name: "{localappdata}\\{{DISPLAY_NAME}}"
|
||||
Type: filesandordirs; Name: "{userappdata}\\{{DISPLAY_NAME}}"
|
||||
Type: filesandordirs; Name: "{tmp}\\{{DISPLAY_NAME}}"
|
||||
|
||||
[Registry]
|
||||
Root: HKCU; Subkey: "Software\\{{DISPLAY_NAME}}"; Flags: uninsdeletekey
|
||||
Root: HKLM; Subkey: "Software\\{{DISPLAY_NAME}}"; Flags: uninsdeletekey
|
||||
|
||||
[Code]
|
||||
function InitializeSetup(): Boolean;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
procedure AppendLog(S: string);
|
||||
begin
|
||||
Exec('taskkill', '/F /IM BearVPN.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
|
||||
Exec('net', 'stop "BearVPNTunnelService"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
|
||||
Exec('sc.exe', 'delete "BearVPNTunnelService"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)
|
||||
SaveStringToFile(ExpandConstant('{tmp}\\{{DISPLAY_NAME}}_installer.log'), S + #13#10, True);
|
||||
end;
|
||||
|
||||
procedure TerminateProcesses();
|
||||
var ResultCode: Integer;
|
||||
begin
|
||||
try
|
||||
Exec('taskkill', '/F /IM {{EXECUTABLE_NAME}}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||
except
|
||||
AppendLog('terminate failed: {{EXECUTABLE_NAME}}');
|
||||
end;
|
||||
try
|
||||
Exec('taskkill', '/F /IM BearVPNCli.exe', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||
except
|
||||
AppendLog('terminate failed: BearVPNCli.exe');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure StopServices();
|
||||
var ResultCode: Integer;
|
||||
begin
|
||||
try
|
||||
Exec('net', 'stop "BearVPNTunnelService"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||
Exec('sc.exe', 'delete "BearVPNTunnelService"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||
except
|
||||
AppendLog('service stop/delete failed: BearVPNTunnelService');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CleanPaths();
|
||||
var ok: Boolean;
|
||||
begin
|
||||
try
|
||||
if DirExists(ExpandConstant('{app}')) then
|
||||
ok := DelTree(ExpandConstant('{app}'), True, True, True)
|
||||
else ok := True;
|
||||
if not ok then AppendLog('delete failed: {app}');
|
||||
except
|
||||
AppendLog('exception deleting: {app}');
|
||||
end;
|
||||
try
|
||||
if DirExists(ExpandConstant('{localappdata}\\{{DISPLAY_NAME}}')) then
|
||||
ok := DelTree(ExpandConstant('{localappdata}\\{{DISPLAY_NAME}}'), True, True, True);
|
||||
if DirExists(ExpandConstant('{userappdata}\\{{DISPLAY_NAME}}')) then
|
||||
ok := DelTree(ExpandConstant('{userappdata}\\{{DISPLAY_NAME}}'), True, True, True);
|
||||
if DirExists(ExpandConstant('{tmp}\\{{DISPLAY_NAME}}')) then
|
||||
ok := DelTree(ExpandConstant('{tmp}\\{{DISPLAY_NAME}}'), True, True, True);
|
||||
except
|
||||
AppendLog('exception deleting user data');
|
||||
end;
|
||||
end;
|
||||
|
||||
function InitializeSetup(): Boolean;
|
||||
begin
|
||||
TerminateProcesses();
|
||||
StopServices();
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
function InitializeUninstall(): Boolean;
|
||||
begin
|
||||
TerminateProcesses();
|
||||
StopServices();
|
||||
CleanPaths();
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user