common.iss 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #define AppExeName "SyncTrayzor.exe"
  2. #define AppRoot "..\.."
  3. #define AppSrc AppRoot + "\src\SyncTrayzor"
  4. #define AppBin AppRoot +"\bin\" + Arch + "\Release"
  5. #define AppExe AppBin + "\SyncTrayzor.exe"
  6. #define AppName GetStringFileInfo(AppExe, "ProductName")
  7. #define AppVersion GetFileVersion(AppExe)
  8. #define AppPublisher "SyncTrayzor"
  9. #define AppURL "https://github.com/canton7/SyncTrayzor"
  10. #define AppDataFolder "SyncTrayzor"
  11. #define RunRegKey "Software\Microsoft\Windows\CurrentVersion\Run"
  12. [Setup]
  13. AppId={{#AppId}
  14. AppName={#AppName} ({#Arch})
  15. AppVersion={#AppVersion}
  16. ;AppVerName={#AppName} {#AppVersion}
  17. AppPublisher={#AppPublisher}
  18. AppPublisherURL={#AppURL}
  19. AppSupportURL={#AppURL}
  20. AppUpdatesURL={#AppURL}
  21. DefaultDirName={pf}\{#AppName}
  22. DefaultGroupName={#AppName}
  23. AllowNoIcons=yes
  24. LicenseFile={#AppRoot}\LICENSE.txt
  25. OutputDir="."
  26. OutputBaseFilename={#AppName}Setup-{#Arch}
  27. SetupIconFile={#AppSrc}\Icons\default.ico
  28. Compression=lzma2/max
  29. ;Compression=None
  30. SolidCompression=yes
  31. PrivilegesRequired=admin
  32. CloseApplications=yes
  33. RestartApplications=no
  34. ; If we try and close CefSharp.BrowserSubprocess.exe we'll fail - it doesn't respond well
  35. ; However if we close *just* SyncTrayzor, that will take care of shutting down CefSharp and syncthing
  36. CloseApplicationsFilter=SyncTrayzor.exe
  37. TouchDate=current
  38. #if "x64" == Arch
  39. ArchitecturesInstallIn64BitMode=x64
  40. ArchitecturesAllowed=x64
  41. #endif
  42. [Languages]
  43. Name: "english"; MessagesFile: "compiler:Default.isl"
  44. [Tasks]
  45. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
  46. [Dirs]
  47. Name: "{userappdata}\{#AppDataFolder}"
  48. [Files]
  49. Source: "{#AppBin}\*"; DestDir: "{app}"; Excludes: "*.xml,*.vshost.*,*.config,*.log,FluentValidation.resources.dll,System.Windows.Interactivity.resources.dll,syncthing.exe,data,logs,ffmpegsumo.dll,d3dcompiler_43.dll,d3dcompiler_47.dll,libEGL.dll,libGLESv2.dll,pdf.dll"; Flags: ignoreversion recursesubdirs
  50. Source: "{#AppBin}\SyncTrayzor.exe.Installer.config"; DestDir: "{app}"; DestName: "SyncTrayzor.exe.config"; Flags: ignoreversion
  51. Source: "{#AppSrc}\Icons\default.ico"; DestDir: "{app}"; Flags: ignoreversion
  52. Source: "{#AppRoot}\*.md"; DestDir: "{app}"; Flags: ignoreversion
  53. Source: "{#AppRoot}\*.txt"; DestDir: "{app}"; Flags: ignoreversion
  54. Source: "*.dll"; DestDir: "{app}"; Flags: ignoreversion
  55. Source: "syncthing.exe"; DestDir: "{app}"; DestName: "syncthing.exe"; Flags: ignoreversion
  56. Source: "..\dotNet451Setup.exe"; DestDir: {tmp}; Flags: deleteafterinstall; Check: FrameworkIsNotInstalled
  57. [Icons]
  58. Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}"
  59. Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
  60. Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon
  61. [Run]
  62. Filename: "{tmp}\dotNet451Setup.exe"; Parameters: "/passive /promptrestart"; Check: FrameworkIsNotInstalled; StatusMsg: "Microsoft .NET Framework 4.5.1 is being installed. Please wait..."
  63. Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
  64. [Code]
  65. function FrameworkIsNotInstalled: Boolean;
  66. var
  67. exists: boolean;
  68. release: cardinal;
  69. begin
  70. exists := RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', release);
  71. result := not exists or (release < 378758);
  72. end;
  73. procedure BumpInstallCount;
  74. var
  75. fileContents: AnsiString;
  76. installCount: integer;
  77. begin
  78. { Increment the install count in InstallCount.txt if it exists, or create it with the contents '1' if it doesn't }
  79. if LoadStringFromFile(ExpandConstant('{app}\InstallCount.txt'), fileContents) then
  80. begin
  81. installCount := StrTointDef(Trim(string(fileContents)), 0) + 1;
  82. end
  83. else
  84. begin
  85. installCount := 1;
  86. end;
  87. SaveStringToFile(ExpandConstant('{app}\InstallCount.txt'), IntToStr(installCount), False);
  88. end;
  89. procedure CurStepChanged(CurStep: TSetupStep);
  90. var
  91. FindRec: TFindRec;
  92. FolderPath: String;
  93. FilePath: String;
  94. begin
  95. if CurStep = ssInstall then
  96. begin
  97. BumpInstallCount();
  98. { We might be being run from ProcessRunner.exe, *and* we might be trying to update it. Funsies. Let's rename it (which Windows lets us do) }
  99. DeleteFile(ExpandConstant('{app}\ProcessRunner.exe.old'));
  100. RenameFile(ExpandConstant('{app}\ProcessRunner.exe'), ExpandConstant('{app}\ProcessRunner.exe.old'));
  101. Log(ExpandConstant('Looking for resource files in {app}\*'));
  102. { Remove resource files. This means that out-of-date languages will be removed, which (as a last-ditch resore) will alert maintainers that something's wrong }
  103. if FindFirst(ExpandConstant('{app}\*'), FindRec) then
  104. begin
  105. try
  106. repeat
  107. if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and (FindRec.Name <> '.') and (FindRec.Name <> '..') then
  108. begin
  109. FolderPath := ExpandConstant('{app}\') + FindRec.Name;
  110. FilePath := FolderPath + '\SyncTrayzor.resources.dll';
  111. if DeleteFile(FilePath) then
  112. begin
  113. Log('Deleted ' + FilePath);
  114. if DelTree(FolderPath, True, False, False) then
  115. Log('Deleted ' + FolderPath);
  116. end;
  117. end;
  118. until not FindNext(FindRec);
  119. finally
  120. FindClose(FindRec);
  121. end;
  122. end;
  123. end
  124. end;
  125. [UninstallDelete]
  126. Type: files; Name: "{app}\ProcessRunner.exe.old"
  127. Type: files; Name: "{app}\InstallCount.txt"
  128. Type: filesandordirs; Name: "{userappdata}\{#AppDataFolder}"
  129. Type: filesandordirs; Name: "{localappdata}\{#AppDataFolder}"