调整打包文件
This commit is contained in:
103
installer.nsi
103
installer.nsi
@@ -1,31 +1,17 @@
|
||||
Unicode True
|
||||
SetCompressor /SOLID lzma
|
||||
SetCompressorDictSize 64
|
||||
RequestExecutionLevel user
|
||||
|
||||
!include "MUI2.nsh"
|
||||
!include "LogicLib.nsh"
|
||||
|
||||
!define PROJECT_ROOT "."
|
||||
!define DIST_ROOT "${PROJECT_ROOT}\\dist\\pqAutomationApp"
|
||||
!define DIST_ROOT "${PROJECT_ROOT}\dist\pqAutomationApp"
|
||||
!define APP_EXE "pqAutomationApp.exe"
|
||||
!define APP_ID "PQAutomationApp"
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Detect Python from PATH
|
||||
; ------------------------------------------------------------
|
||||
!define PYTHON_CMD "python"
|
||||
|
||||
!system '"${PYTHON_CMD}" -V > python_check.txt 2>&1'
|
||||
!searchparse /file python_check.txt "Python " PY_VER ""
|
||||
!if "${PY_VER}" == ""
|
||||
!error "Python not found. Ensure python.exe is available in PATH."
|
||||
!endif
|
||||
!delfile python_check.txt
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Extract APP_NAME and APP_VERSION from Python code
|
||||
; (App version file may contain Unicode, so we use Python to output ASCII)
|
||||
; ------------------------------------------------------------
|
||||
!system '"${PYTHON_CMD}" -c "import app_version; print(app_version.APP_NAME)" > app_name.txt'
|
||||
!system '"${PYTHON_CMD}" -c "import app_version; print(app_version.APP_VERSION)" > app_version.txt'
|
||||
|
||||
@@ -35,20 +21,22 @@ RequestExecutionLevel user
|
||||
!delfile "app_name.txt"
|
||||
!delfile "app_version.txt"
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Registry Keys
|
||||
; ------------------------------------------------------------
|
||||
!define UNINSTALL_REG_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${APP_ID}"
|
||||
!define APP_REG_KEY "Software\\${APP_ID}"
|
||||
!if /FileExists "${DIST_ROOT}\${APP_EXE}"
|
||||
!else
|
||||
!error "Executable not found: ${DIST_ROOT}\${APP_EXE}. Please build using PyInstaller first."
|
||||
!endif
|
||||
|
||||
!define UNINSTALL_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_ID}"
|
||||
!define APP_REG_KEY "Software\${APP_ID}"
|
||||
|
||||
Name "${APP_NAME} ${APP_VERSION}"
|
||||
OutFile "dist\\PQAutomationApp_Setup_${APP_VERSION}.exe"
|
||||
InstallDir "$LOCALAPPDATA\\Programs\\${APP_ID}"
|
||||
OutFile "dist\PQAutomationApp_Setup_${APP_VERSION}.exe"
|
||||
InstallDir "$LOCALAPPDATA\Programs\${APP_ID}"
|
||||
InstallDirRegKey HKCU "${APP_REG_KEY}" "InstallDir"
|
||||
|
||||
!define MUI_ABORTWARNING
|
||||
!define MUI_ICON "assets\\pq.ico"
|
||||
!define MUI_UNICON "assets\\pq.ico"
|
||||
!define MUI_ICON "assets\pq.ico"
|
||||
!define MUI_UNICON "assets\pq.ico"
|
||||
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
@@ -59,71 +47,46 @@ InstallDirRegKey HKCU "${APP_REG_KEY}" "InstallDir"
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
!insertmacro MUI_UNPAGE_FINISH
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
!insertmacro MUI_LANGUAGE "SimpChinese"
|
||||
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Init
|
||||
; ------------------------------------------------------------
|
||||
Function .onInit
|
||||
IfFileExists "${DIST_ROOT}\\${APP_EXE}" +2 0
|
||||
MessageBox MB_ICONSTOP|MB_OK "Executable not found: ${DIST_ROOT}\\${APP_EXE}$\r$\nPlease build using PyInstaller first."
|
||||
IfFileExists "${DIST_ROOT}\\${APP_EXE}" +2 0
|
||||
Abort
|
||||
FunctionEnd
|
||||
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Installation Section
|
||||
; ------------------------------------------------------------
|
||||
Section "Main Installation" SEC_MAIN
|
||||
SetOutPath "$INSTDIR"
|
||||
CreateDirectory "$INSTDIR"
|
||||
CreateDirectory "$INSTDIR\\internal"
|
||||
CreateDirectory "$INSTDIR\\settings"
|
||||
|
||||
File "${DIST_ROOT}\\${APP_EXE}"
|
||||
File "${DIST_ROOT}\${APP_EXE}"
|
||||
|
||||
SetOutPath "$INSTDIR\\internal"
|
||||
File /r "${DIST_ROOT}\\internal\\*.*"
|
||||
SetOutPath "$INSTDIR\internal"
|
||||
File /r /x "*.pdb" /x "*.lib" /x "*.exp" /x "*.h" /x "__pycache__" /x "*.pyc" "${DIST_ROOT}\internal\*.*"
|
||||
|
||||
IfFileExists "${PROJECT_ROOT}\\settings\\pq_config.json" 0 +3
|
||||
SetOutPath "$INSTDIR\\settings"
|
||||
File /oname=pq_config.json "${PROJECT_ROOT}\\settings\\pq_config.json"
|
||||
IfFileExists "$INSTDIR\settings\pq_config.json" +3 0
|
||||
SetOutPath "$INSTDIR\settings"
|
||||
File /oname=pq_config.json "${PROJECT_ROOT}\settings\pq_config.json"
|
||||
|
||||
WriteUninstaller "$INSTDIR\\Uninstall.exe"
|
||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||
|
||||
WriteRegStr HKCU "${APP_REG_KEY}" "InstallDir" "$INSTDIR"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "DisplayName" "${APP_NAME}"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "DisplayVersion" "${APP_VERSION}"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "InstallLocation" "$INSTDIR"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "DisplayIcon" "$INSTDIR\\${APP_EXE}"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "DisplayIcon" "$INSTDIR\${APP_EXE}"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "Publisher" "Moka"
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "UninstallString" "$\"$INSTDIR\\Uninstall.exe$\""
|
||||
WriteRegStr HKCU "${UNINSTALL_REG_KEY}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
|
||||
WriteRegDWORD HKCU "${UNINSTALL_REG_KEY}" "NoModify" 1
|
||||
WriteRegDWORD HKCU "${UNINSTALL_REG_KEY}" "NoRepair" 1
|
||||
|
||||
CreateDirectory "$SMPROGRAMS\\${APP_NAME}"
|
||||
CreateShortcut "$SMPROGRAMS\\${APP_NAME}\\${APP_NAME}.lnk" "$INSTDIR\\${APP_EXE}"
|
||||
CreateShortcut "$SMPROGRAMS\\${APP_NAME}\\Uninstall ${APP_NAME}.lnk" "$INSTDIR\\Uninstall.exe"
|
||||
CreateShortcut "$DESKTOP\\${APP_NAME}.lnk" "$INSTDIR\\${APP_EXE}"
|
||||
CreateDirectory "$SMPROGRAMS\${APP_NAME}"
|
||||
CreateShortcut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${APP_EXE}"
|
||||
CreateShortcut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${APP_EXE}"
|
||||
SectionEnd
|
||||
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Uninstall Section
|
||||
; ------------------------------------------------------------
|
||||
Section "Uninstall"
|
||||
Delete "$DESKTOP\\${APP_NAME}.lnk"
|
||||
Delete "$SMPROGRAMS\\${APP_NAME}\\${APP_NAME}.lnk"
|
||||
Delete "$SMPROGRAMS\\${APP_NAME}\\Uninstall ${APP_NAME}.lnk"
|
||||
RMDir "$SMPROGRAMS\\${APP_NAME}"
|
||||
Delete "$DESKTOP\${APP_NAME}.lnk"
|
||||
Delete "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk"
|
||||
RMDir "$SMPROGRAMS\${APP_NAME}"
|
||||
|
||||
Delete "$INSTDIR\\${APP_EXE}"
|
||||
Delete "$INSTDIR\\Uninstall.exe"
|
||||
Delete "$INSTDIR\\settings\\pq_config.json"
|
||||
RMDir /r "$INSTDIR\\internal"
|
||||
RMDir /r "$INSTDIR\\settings"
|
||||
Delete "$INSTDIR\${APP_EXE}"
|
||||
Delete "$INSTDIR\Uninstall.exe"
|
||||
RMDir /r "$INSTDIR\internal"
|
||||
RMDir /r "$INSTDIR\settings"
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
DeleteRegKey HKCU "${UNINSTALL_REG_KEY}"
|
||||
|
||||
Reference in New Issue
Block a user