@@ -96,7 +96,8 @@ Source: "tools\*"; DestDir: "{app}\tools"; Flags: ignoreversion
9696Source : " {#ProductJsonPath}" ; DestDir : " {code:GetDestDir}\resources\app" ; Flags : ignoreversion
9797#ifdef AppxPackageName
9898#if " user" == InstallTarget
99- Source : " appx\*" ; DestDir : " {app} \appx" ; BeforeInstall : RemoveAppxPackage; AfterInstall : AddAppxPackage; Flags : ignoreversion ; Check : IsWindows11OrLater
99+ Source : " appx\{#AppxPackage}" ; DestDir : " {app} \appx" ; BeforeInstall : RemoveAppxPackage; Flags : ignoreversion ; Check : IsWindows11OrLater
100+ Source : " appx\{#AppxPackageDll}" ; DestDir : " {app} \appx" ; AfterInstall : AddAppxPackage; Flags : ignoreversion ; Check : IsWindows11OrLater
100101#endif
101102#endif
102103
@@ -1479,11 +1480,12 @@ begin
14791480 Log(S);
14801481end ;
14811482
1482- function AppxPackageInstalled (var ResultCode: Integer): Boolean;
1483+ function AppxPackageInstalled (const name : String; var ResultCode: Integer): Boolean;
14831484begin
14841485 AppxPackageFullname := ' ' ;
14851486 try
1486- ExecAndLogOutput(' powershell.exe' , ' -NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes(' Get-AppxPackage -Name '' {#AppxPackageName}'' | Select-Object -ExpandProperty PackageFullName' ), ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode, @ExecAndGetFirstLineLog);
1487+ Log(' Get-AppxPackage for package with name: ' + name );
1488+ ExecAndLogOutput(' powershell.exe' , ' -NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes(' Get-AppxPackage -Name '' ' + name + ' '' | Select-Object -ExpandProperty PackageFullName' ), ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode, @ExecAndGetFirstLineLog);
14871489 except
14881490 Log(GetExceptionMessage);
14891491 end ;
@@ -1497,17 +1499,29 @@ procedure AddAppxPackage();
14971499var
14981500 AddAppxPackageResultCode: Integer;
14991501begin
1500- if not AppxPackageInstalled(AddAppxPackageResultCode) then begin
1502+ if not AppxPackageInstalled(ExpandConstant(' {#AppxPackageName}' ), AddAppxPackageResultCode) then begin
1503+ Log(' Installing appx ' + AppxPackageFullname + ' ...' );
15011504 ShellExec(' ' , ' powershell.exe' , ' -NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes(' Add-AppxPackage -Path '' ' + ExpandConstant(' {app}\appx\{#AppxPackage}' ) + ' '' -ExternalLocation '' ' + ExpandConstant(' {app}\appx' ) + ' '' ' ), ' ' , SW_HIDE, ewWaitUntilTerminated, AddAppxPackageResultCode);
1505+ Log(' Add-AppxPackage complete.' );
15021506 end ;
15031507end ;
15041508
15051509procedure RemoveAppxPackage ();
15061510var
15071511 RemoveAppxPackageResultCode: Integer;
15081512begin
1509- if AppxPackageInstalled(RemoveAppxPackageResultCode) then begin
1513+ // Remove the old context menu package
1514+ // Following condition can be removed after two versions.
1515+ if QualityIsInsiders() and AppxPackageInstalled(' Microsoft.VSCodeInsiders' , RemoveAppxPackageResultCode) then begin
1516+ Log(' Deleting old appx ' + AppxPackageFullname + ' installation...' );
15101517 ShellExec(' ' , ' powershell.exe' , ' -NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes(' Remove-AppxPackage -Package '' ' + AppxPackageFullname + ' '' ' ), ' ' , SW_HIDE, ewWaitUntilTerminated, RemoveAppxPackageResultCode);
1518+ DeleteFile(ExpandConstant(' {app}\appx\code_insiders_explorer_{#Arch}.appx' ));
1519+ DeleteFile(ExpandConstant(' {app}\appx\code_insiders_explorer_command.dll' ));
1520+ end ;
1521+ if AppxPackageInstalled(ExpandConstant(' {#AppxPackageName}' ), RemoveAppxPackageResultCode) then begin
1522+ Log(' Removing current ' + AppxPackageFullname + ' appx installation...' );
1523+ ShellExec(' ' , ' powershell.exe' , ' -NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes(' Remove-AppxPackage -Package '' ' + AppxPackageFullname + ' '' ' ), ' ' , SW_HIDE, ewWaitUntilTerminated, RemoveAppxPackageResultCode);
1524+ Log(' Remove-AppxPackage for current appx installation complete.' );
15111525 end ;
15121526end ;
15131527#endif
0 commit comments