installer-preserve-files.nsi 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Unicode true
  2. Name "ZCode preserve-files smoke"
  3. OutFile "${OUTPUT_FILE}"
  4. InstallDir "$TEMP\zcode-preserve-files-smoke"
  5. RequestExecutionLevel user
  6. SilentInstall silent
  7. !addincludedir "${NSIS_INCLUDE_DIR}"
  8. !addincludedir "${ELECTRON_BUILDER_NSIS_INCLUDE_DIR}"
  9. !addplugindir /x86-unicode "${NSIS_PLUGIN_DIR}"
  10. !include "LogicLib.nsh"
  11. !define APP_FILENAME "ZCode"
  12. !define APP_ID "dev.zcode.preserve-files-smoke"
  13. !define UNINSTALL_FILENAME "uninstaller.exe"
  14. !define isUpdated `1 == 1`
  15. ; This fixture has no electron-builder uninstaller.nsh section; use a normal function for log smoke coverage.
  16. !ifdef BUILD_UNINSTALLER
  17. !define ZCODE_UNINSTALLER_FUNCTION_PREFIX ""
  18. !endif
  19. Var appExe
  20. !include "${ZCODE_INSTALLER_NSH}"
  21. Section
  22. SetOutPath "$INSTDIR"
  23. File /oname=ZCode.exe "${FIXTURE_EXE}"
  24. StrCpy $appExe "$INSTDIR\ZCode.exe"
  25. !ifndef OMIT_MANIFEST
  26. FileOpen $0 "$INSTDIR\.zcode-install-manifest" w
  27. FileWrite $0 "owned-by-zcode.txt$\r$\n"
  28. FileWrite $0 "..\user-data.txt$\r$\n"
  29. FileClose $0
  30. !endif
  31. !ifdef FAIL_DELETE
  32. ; Keep the file handle open so Windows denies the manifest cleanup delete.
  33. FileOpen $0 "$INSTDIR\owned-by-zcode.txt" w
  34. FileWrite $0 "locked app payload"
  35. !else
  36. FileOpen $0 "$INSTDIR\owned-by-zcode.txt" w
  37. FileWrite $0 "old app payload"
  38. FileClose $0
  39. !endif
  40. FileOpen $0 "$INSTDIR\user-data.txt" w
  41. FileWrite $0 "keep me"
  42. FileClose $0
  43. !insertmacro customRemoveFiles
  44. IfFileExists "$INSTDIR\owned-by-zcode.txt" 0 zcodeOwnedRemoved
  45. StrCpy $1 "present"
  46. Goto zcodeWriteMarker
  47. zcodeOwnedRemoved:
  48. StrCpy $1 "removed"
  49. zcodeWriteMarker:
  50. FileOpen $0 "$INSTDIR\remove-result.txt" w
  51. FileWrite $0 "$1"
  52. FileClose $0
  53. SectionEnd