Skip to content

Commit 73f0894

Browse files
authored
fix: remove unused appx package (microsoft#258741)
* fix: remove unused appx package * fix: inno compilation * chore: reduce the number of remove and add commands
1 parent 64b6f08 commit 73f0894

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

build/gulpfile.vscode.win32.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function buildWin32Setup(arch, target) {
114114

115115
if (quality !== 'exploration') {
116116
definitions['AppxPackage'] = `${quality === 'stable' ? 'code' : 'code_insider'}_${arch}.appx`;
117+
definitions['AppxPackageDll'] = `${quality === 'stable' ? 'code' : 'code_insider'}_explorer_command_${arch}.dll`;
117118
definitions['AppxPackageName'] = `${product.win32AppUserModelId}`;
118119
}
119120

build/win32/code.iss

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ Source: "tools\*"; DestDir: "{app}\tools"; Flags: ignoreversion
9696
Source: "{#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);
14801481
end;
14811482
1482-
function AppxPackageInstalled(var ResultCode: Integer): Boolean;
1483+
function AppxPackageInstalled(const name: String; var ResultCode: Integer): Boolean;
14831484
begin
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();
14971499
var
14981500
AddAppxPackageResultCode: Integer;
14991501
begin
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;
15031507
end;
15041508
15051509
procedure RemoveAppxPackage();
15061510
var
15071511
RemoveAppxPackageResultCode: Integer;
15081512
begin
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;
15121526
end;
15131527
#endif

0 commit comments

Comments
 (0)