installer-nsh-smoke.nsi 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Unicode true
  2. Name "ZCode installer.nsh smoke"
  3. OutFile "${OUTPUT_FILE}"
  4. InstallDir "$TEMP\zcode-installer-nsh-smoke"
  5. RequestExecutionLevel user
  6. SilentInstall silent
  7. !addincludedir "${NSIS_INCLUDE_DIR}"
  8. !addincludedir "${ELECTRON_BUILDER_NSIS_INCLUDE_DIR}"
  9. !include "LogicLib.nsh"
  10. !ifndef BUILD_UNINSTALLER
  11. !include "MUI2.nsh"
  12. !include "StrContains.nsh"
  13. !endif
  14. !define APP_DESCRIPTION "ZCode NSIS smoke fixture"
  15. !define APP_FILENAME "ZCode"
  16. !define APP_ID "dev.zcode.installer-nsh-smoke"
  17. !define UNINSTALL_FILENAME "uninstaller.exe"
  18. ; This fixture invokes the cleanup macro from a normal section; electron-builder's real uninstaller uses un.*.
  19. !ifdef BUILD_UNINSTALLER
  20. !define ZCODE_UNINSTALLER_FUNCTION_PREFIX ""
  21. !endif
  22. ; Simulate a manually launched overwrite installer without --updated.
  23. !define isUpdated `1 == 0`
  24. !define allowToChangeInstallationDirectory
  25. !define ZCODE_INSTALLER_DEFAULT_LOG_PATH "${DEFAULT_LOG_PATH}"
  26. !define ZCODE_INSTALLER_ELEVATED_LOG_PATH "${ELEVATED_LOG_PATH}"
  27. !ifdef FORCE_ELEVATED_INNER
  28. !define ZCODE_INSTALLER_IS_ELEVATED_INNER `1 == 1`
  29. !endif
  30. Var appExe
  31. Var launchLink
  32. Var newStartMenuLink
  33. Var newDesktopLink
  34. Var keepShortcuts
  35. !include "${ZCODE_INSTALLER_NSH}"
  36. ; 回归原因:electron-builder 异步生成 header 时,自定义 include 可能先于插件目录注册。
  37. ; 普通场景使用真实 UAC 判据,避免恒假替身掩盖插件尚未可用的编译错误。
  38. !addplugindir /x86-unicode "${NSIS_PLUGIN_DIR}"
  39. !ifndef BUILD_UNINSTALLER
  40. ; electron-builder inserts customHeader after assistedInstaller.nsh generated the directory page.
  41. !insertmacro customHeader
  42. !ifdef allowToChangeInstallationDirectory
  43. !error "customHeader must enable shortcut preservation for manual overwrite"
  44. !endif
  45. !insertmacro customPageAfterChangeDir
  46. Function .onInit
  47. !insertmacro preInit
  48. FunctionEnd
  49. !endif
  50. Section
  51. SetOutPath "$INSTDIR"
  52. File /oname=ZCode.exe "${FIXTURE_EXE}"
  53. StrCpy $appExe "$INSTDIR\ZCode.exe"
  54. StrCpy $launchLink "$INSTDIR\stale-target.exe"
  55. StrCpy $newStartMenuLink "$INSTDIR\start-menu.lnk"
  56. StrCpy $newDesktopLink "$INSTDIR\desktop.lnk"
  57. StrCpy $keepShortcuts "true"
  58. !ifdef PRECREATE_SHORTCUTS
  59. !ifdef STALE_SHORTCUTS
  60. CreateShortCut "$newStartMenuLink" "$INSTDIR\stale-target.exe" "--stale"
  61. CreateShortCut "$newDesktopLink" "$INSTDIR\stale-target.exe" "--stale"
  62. !else
  63. CreateShortCut "$newStartMenuLink" "$appExe" "--preserved"
  64. CreateShortCut "$newDesktopLink" "$appExe" "--preserved"
  65. !endif
  66. !ifndef BUILD_UNINSTALLER
  67. Push "$newStartMenuLink"
  68. Call ZCodeReadShortcutTarget
  69. Pop $R8
  70. FileOpen $0 "$INSTDIR\read-shortcut-target.txt" w
  71. FileWrite $0 "$R8"
  72. FileClose $0
  73. !endif
  74. !endif
  75. !ifndef BUILD_UNINSTALLER
  76. SetDetailsPrint none
  77. !insertmacro customInit
  78. ; The real electron-builder template invokes these hooks at the same points.
  79. !insertmacro customInstallSectionStarted
  80. !insertmacro customInstallCleanupStarted
  81. !insertmacro customInstallCleanupCompleted
  82. !insertmacro customInstallExtractStarted
  83. !insertmacro customInstallExtractCompleted
  84. !insertmacro customInstallShortcutsStarted
  85. !insertmacro customInstallShortcutsCompleted
  86. !insertmacro customInstall
  87. !endif
  88. FileOpen $0 "$INSTDIR\launch-link.txt" w
  89. FileWrite $0 "$launchLink"
  90. FileClose $0
  91. ; Expand cleanup diagnostics in the uninstaller smoke fixture so /WX checks the reference.
  92. !ifdef BUILD_UNINSTALLER
  93. !insertmacro customRemoveFiles
  94. !endif
  95. SectionEnd