Skip to content

Commit ae4cf3b

Browse files
committed
Fix issues with Windows installer
Don't reuse the old installation dir since it might not be compatible with the new layout. Ensure previous legacy install is cleaned up to avoid plugin being installed twice.
1 parent 170b1dd commit ae4cf3b

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

.github/scripts/Package-Windows.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function Package {
119119
Log-Information 'Creating InnoSetup installer...'
120120
Push-Location -Stack BuildTemp
121121
Ensure-Location -Path "${ProjectRoot}/release"
122+
Remove-Item -Path Package -Recurse -Force -ErrorAction SilentlyContinue
122123
Copy-Item -Path ${Configuration} -Destination Package -Recurse
123124
Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer"
124125
Remove-Item -Path Package -Recurse

cmake/windows/resources/installer-Windows.iss.in

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
#define MyAppVersion "@CMAKE_PROJECT_VERSION@"
33
#define MyAppPublisher "@PLUGIN_AUTHOR@"
44
#define MyAppURL "@PLUGIN_WEBSITE@"
5+
#define MyAppId "@UUID_APP@"
56

67
[Setup]
78
; NOTE: The value of AppId uniquely identifies this application.
89
; Do not use the same AppId value in installers for other applications.
910
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
10-
AppId={{@UUID_APP@}
11+
AppId={{{#MyAppId}}
1112
AppName={#MyAppName}
1213
AppVersion={#MyAppVersion}
1314
AppPublisher={#MyAppPublisher}
@@ -20,6 +21,7 @@ OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer
2021
Compression=lzma
2122
SolidCompression=yes
2223
DirExistsWarning=no
24+
UsePreviousAppDir=no
2325
SetupIconFile=installer.ico
2426
UninstallDisplayIcon={app}\advanced-scene-switcher\data\res\images\logo.ico
2527
DisableDirPage=no
@@ -51,10 +53,34 @@ begin
5153
);
5254
end;
5355

54-
// credit where it's due :
55-
// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45
5656
function GetDirName(Value: string): string;
5757
begin
5858
Result := ExpandConstant('{commonappdata}\obs-studio\plugins');
5959
end;
6060

61+
// Remove files placed by the legacy installer (obs-plugins/64bit and
62+
// data/obs-plugins layout) so the plugin is not loaded twice by OBS.
63+
// We read InstallLocation from our own previous uninstall entry, which is
64+
// the exact directory the old installer used regardless of OBS install path.
65+
procedure RemoveLegacyFiles();
66+
var
67+
OldInstallPath: string;
68+
UninstallKey: string;
69+
begin
70+
UninstallKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + '{' + '{#MyAppId}' + '}_is1';
71+
if not RegQueryStringValue(HKLM, UninstallKey, 'InstallLocation', OldInstallPath) then
72+
Exit;
73+
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher.dll');
74+
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher.pdb');
75+
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-lib.dll');
76+
DeleteFile(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-lib.pdb');
77+
DelTree(OldInstallPath + '\obs-plugins\64bit\advanced-scene-switcher-plugins', True, True, True);
78+
DelTree(OldInstallPath + '\data\obs-plugins\advanced-scene-switcher', True, True, True);
79+
end;
80+
81+
procedure CurStepChanged(CurStep: TSetupStep);
82+
begin
83+
if CurStep = ssInstall then
84+
RemoveLegacyFiles();
85+
end;
86+

0 commit comments

Comments
 (0)