-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #92 - appsettings.json is overwritten during installation
- Loading branch information
1 parent
708856b
commit dcc7261
Showing
1 changed file
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,12 @@ | |
AppId={{5B8E7506-21A8-49BB-B144-6523D0E43E34} | ||
AppName={#MyAppName} | ||
AppVersion={#MyAppVersion} | ||
AppVerName={#MyAppName} | ||
AppVerName={#MyAppName} v{#MyAppVersion} | ||
AppPublisher={#MyAppPublisher} | ||
AppPublisherURL={#MyAppURL} | ||
AppSupportURL={#MyAppURL} | ||
AppUpdatesURL={#MyAppURL} | ||
VersionInfoVersion={#MyAppVersion} | ||
DefaultDirName={autopf}\{#MyAppName} | ||
DisableProgramGroupPage=yes | ||
LicenseFile=..\Binner.Web\LICENSE | ||
|
@@ -28,19 +29,21 @@ UninstallDisplayIcon={app}\{#MyAppExeName} | |
WizardImageFile=.\WizardLarge.bmp | ||
WizardSmallImageFile=.\WizardSmall.bmp | ||
CloseApplications=force | ||
UsePreviousTasks=no | ||
|
||
|
||
[Languages] | ||
Name: "english"; MessagesFile: "compiler:Default.isl" | ||
|
||
[CustomMessages] | ||
UninstallingService=Uninstalling existing {#MyAppName} service... | ||
InstallingService=Installing {#MyAppName} service... | ||
InstallingService=Installing {#MyAppName} {#MyAppVersion} service... | ||
InstallingCertificates=Installing certificates... | ||
StartingApp=Starting {#MyAppName}... | ||
|
||
[Tasks] | ||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked | ||
Name: "keepconfiguration"; Description: "Keep existing configuration" | ||
Name: "installservice"; Description: "Install {#MyAppName} as a Windows service" | ||
|
||
[Files] | ||
|
@@ -89,12 +92,49 @@ external '[email protected] stdcall'; | |
procedure CurStepChanged(CurStep: TSetupStep); | ||
var | ||
ResultCode : Integer; | ||
SourcePath: string; | ||
DestPath: string; | ||
begin | ||
// backup the appsettings | ||
if CurStep = ssInstall then | ||
begin | ||
if WizardIsTaskSelected('keepconfiguration') then | ||
begin | ||
SourcePath := ExpandConstant('{app}\appsettings.json'); | ||
DestPath := ExpandConstant('{app}\appsettings.installerbackup.json'); | ||
if FileExists(SourcePath) then | ||
begin | ||
if not FileCopy(SourcePath, DestPath, False) then | ||
begin | ||
Log(Format('Backed up %s to %s', [SourcePath, DestPath])); | ||
end | ||
else | ||
begin | ||
Log(Format('Failed to Backup %s', [SourcePath])); | ||
end; | ||
end; | ||
end; | ||
end; | ||
// Install the service if the task was checked by the user | ||
if CurStep = ssPostInstall then | ||
begin | ||
Log('Post install'); | ||
if WizardIsTaskSelected('keepconfiguration') then | ||
begin | ||
// restore the appsettings | ||
SourcePath := ExpandConstant('{app}\appsettings.json'); | ||
DestPath := ExpandConstant('{app}\appsettings.installerbackup.json'); | ||
if FileExists(DestPath) then | ||
begin | ||
if FileCopy(DestPath, SourcePath, False) then | ||
begin | ||
Log(Format('Restored %s from Backup %s', [SourcePath, DestPath])); | ||
end; | ||
end; | ||
end; | ||
// Install the certificate as trusted before launching apps | ||
WizardForm.StatusLabel.Caption := CustomMessage('InstallingCertificates'); | ||
WizardForm.StatusLabel.Show(); | ||
|