mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-04 17:34:07 +02:00
Add a portable installer that uses the full installer with a custom flag
This commit is contained in:
parent
b0261342ff
commit
4ee99376fd
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@ x86/
|
||||
[Oo]bj/
|
||||
bld/*
|
||||
!bld/gen_full.iss
|
||||
!bld/gen_port.iss
|
||||
!bld/gen_upd.iss
|
||||
!bld/Resources
|
||||
|
||||
|
@ -23,6 +23,7 @@ OutputBaseFilename={#MyAppName}
|
||||
VersionInfoVersion={#MyAppVersion}
|
||||
LicenseFile=.\Resources\LICENSE
|
||||
SetupIconFile=.\Resources\icon.ico
|
||||
Uninstallable=TDIsUninstallable
|
||||
UninstallDisplayName={#MyAppName}
|
||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||||
Compression=lzma
|
||||
@ -41,7 +42,7 @@ Source: "..\bin\x86\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignorever
|
||||
Source: "..\bin\x86\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.xml,devtools_resources.pak,d3dcompiler_43.dll"
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Check: TDIsUninstallable
|
||||
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
@ -56,6 +57,7 @@ Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\Cache"
|
||||
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}\GPUCache"
|
||||
|
||||
[Code]
|
||||
var IsPortableInstallation: Boolean;
|
||||
var UpdatePath: String;
|
||||
|
||||
function TDGetNetFrameworkVersion: Cardinal; forward;
|
||||
@ -63,8 +65,16 @@ function TDGetNetFrameworkVersion: Cardinal; forward;
|
||||
{ Check .NET Framework version on startup, ask user if they want to proceed if older than 4.5.2. }
|
||||
function InitializeSetup: Boolean;
|
||||
begin
|
||||
IsPortableInstallation := ExpandConstant('{param:PORTABLEINSTALL}') = '1'
|
||||
UpdatePath := ExpandConstant('{param:UPDATEPATH}')
|
||||
|
||||
if IsPortableInstallation and (UpdatePath = '') then
|
||||
begin
|
||||
MsgBox('The /PORTABLEINSTALL flag requires the /UPDATEPATH parameter.', mbCriticalError, MB_OK);
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if TDGetNetFrameworkVersion() >= 379893 then
|
||||
begin
|
||||
Result := True;
|
||||
@ -115,6 +125,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Create a 'makeportable' file if running in portable mode. }
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
if (CurStep = ssPostInstall) and IsPortableInstallation then
|
||||
begin
|
||||
while not SaveStringToFile(ExpandConstant('{app}\makeportable'), '', False) do
|
||||
begin
|
||||
if MsgBox('Could not create a ''makeportable'' file in the installation folder. If the file is not present, the installation will not be fully portable.', mbCriticalError, MB_RETRYCANCEL) <> IDRETRY then
|
||||
begin
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Returns true if the installer should create uninstallation entries (i.e. not running in portable or full update mode). }
|
||||
function TDIsUninstallable: Boolean;
|
||||
begin
|
||||
Result := (UpdatePath = '') and not IsPortableInstallation
|
||||
end;
|
||||
|
||||
{ Return DWORD value containing the build version of .NET Framework. }
|
||||
function TDGetNetFrameworkVersion: Cardinal;
|
||||
var FrameworkVersion: Cardinal;
|
||||
|
150
bld/gen_port.iss
Normal file
150
bld/gen_port.iss
Normal file
@ -0,0 +1,150 @@
|
||||
; Script generated by the Inno Script Studio Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "TweetDuck"
|
||||
#define MyAppPublisher "chylex"
|
||||
#define MyAppURL "https://tweetduck.chylex.com"
|
||||
#define MyAppExeName "TweetDuck.exe"
|
||||
|
||||
#define MyAppVersion GetFileVersion("..\bin\x86\Release\TweetDuck.exe")
|
||||
|
||||
[Setup]
|
||||
AppId={{8C25A716-7E11-4AAD-9992-8B5D0C78AE06}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={pf}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
OutputBaseFilename={#MyAppName}.Portable
|
||||
VersionInfoVersion={#MyAppVersion}
|
||||
LicenseFile=.\Resources\LICENSE
|
||||
SetupIconFile=.\Resources\icon.ico
|
||||
Uninstallable=no
|
||||
UsePreviousAppDir=no
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
InternalCompressLevel=max
|
||||
MinVersion=0,6.1
|
||||
|
||||
#include <idp.iss>
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Files]
|
||||
Source: "..\bin\x86\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall shellexec
|
||||
|
||||
[Code]
|
||||
function TDGetNetFrameworkVersion: Cardinal; forward;
|
||||
function TDGetAppVersionClean: String; forward;
|
||||
procedure TDExecuteFullDownload; forward;
|
||||
|
||||
{ Check .NET Framework version on startup, ask user if they want to proceed if older than 4.5.2, and prepare full download package. }
|
||||
function InitializeSetup: Boolean;
|
||||
begin
|
||||
idpAddFile('https://github.com/{#MyAppPublisher}/{#MyAppName}/releases/download/'+TDGetAppVersionClean()+'/{#MyAppName}.exe', ExpandConstant('{tmp}\{#MyAppName}.Full.exe'));
|
||||
|
||||
if TDGetNetFrameworkVersion() >= 379893 then
|
||||
begin
|
||||
Result := True;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if (MsgBox('{#MyAppName} requires .NET Framework 4.5.2 or newer,'+#13+#10+'please download it from {#MyAppURL}'+#13+#10+#13+#10'Do you want to proceed with the setup anyway?', mbCriticalError, MB_YESNO or MB_DEFBUTTON2) = IDNO) then
|
||||
begin
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{ Prepare download plugin if there are any files to download, and set the installation path. }
|
||||
procedure InitializeWizard();
|
||||
begin
|
||||
idpDownloadAfter(wpReady);
|
||||
end;
|
||||
|
||||
{ Remove uninstallation data and application to force them to be replaced with updated ones. }
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
begin
|
||||
if CurStep = ssInstall then
|
||||
begin
|
||||
TDExecuteFullDownload();
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Return DWORD value containing the build version of .NET Framework. }
|
||||
function TDGetNetFrameworkVersion: Cardinal;
|
||||
var FrameworkVersion: Cardinal;
|
||||
|
||||
begin
|
||||
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', FrameworkVersion) then
|
||||
begin
|
||||
Result := FrameworkVersion;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
{ Return a cleaned up form of the app version string (removes all .0 suffixes). }
|
||||
function TDGetAppVersionClean: String;
|
||||
var Substr: String;
|
||||
var CleanVersion: String;
|
||||
|
||||
begin
|
||||
CleanVersion := '{#MyAppVersion}'
|
||||
|
||||
while True do
|
||||
begin
|
||||
Substr := Copy(CleanVersion, Length(CleanVersion)-1, 2);
|
||||
|
||||
if (CompareStr(Substr, '.0') <> 0) then
|
||||
begin
|
||||
break;
|
||||
end;
|
||||
|
||||
CleanVersion := Copy(CleanVersion, 1, Length(CleanVersion)-2);
|
||||
end;
|
||||
|
||||
Result := CleanVersion;
|
||||
end;
|
||||
|
||||
{ Run the full package installer if downloaded. }
|
||||
procedure TDExecuteFullDownload;
|
||||
var InstallFile: String;
|
||||
var ResultCode: Integer;
|
||||
|
||||
begin
|
||||
InstallFile := ExpandConstant('{tmp}\{#MyAppName}.Full.exe')
|
||||
WizardForm.ProgressGauge.Style := npbstMarquee;
|
||||
|
||||
try
|
||||
if Exec(InstallFile, '/SP- /SILENT /MERGETASKS="!desktopicon" /UPDATEPATH="'+ExpandConstant('{app}\')+'" /PORTABLEINSTALL=1', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
|
||||
if ResultCode <> 0 then
|
||||
begin
|
||||
DeleteFile(InstallFile);
|
||||
Abort();
|
||||
Exit;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
MsgBox('Could not run the full installer in portable mode. Error: '+SysErrorMessage(ResultCode), mbCriticalError, MB_OK);
|
||||
|
||||
DeleteFile(InstallFile);
|
||||
Abort();
|
||||
Exit;
|
||||
end;
|
||||
finally
|
||||
WizardForm.ProgressGauge.Style := npbstNormal;
|
||||
DeleteFile(InstallFile);
|
||||
end;
|
||||
end;
|
Loading…
Reference in New Issue
Block a user