Skip to content

Commit

Permalink
Single installer contains different AppId
Browse files Browse the repository at this point in the history
  • Loading branch information
kkocdko committed Jan 16, 2025
1 parent 2ebec34 commit ff5ce8a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
35 changes: 11 additions & 24 deletions build/gulpfile.vscode.win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const rcedit = require('rcedit');

const repoPath = path.dirname(__dirname);
const buildPath = (/** @type {string} */ arch) => path.join(path.dirname(repoPath), `VSCode-win32-${arch}`);
const setupDir = (/** @type {string} */ arch, /** @type {string} */ target) => path.join(repoPath, '.build', `win32-${arch}`, `${target}-setup`);
const setupDir = (/** @type {string} */ arch) => path.join(repoPath, '.build', `win32-${arch}`, "setup");
const issPath = path.join(__dirname, 'win32', 'code.iss');
const innoSetupPath = path.join(path.dirname(path.dirname(require.resolve('innosetup'))), 'bin', 'ISCC.exe');
const signWin32Path = path.join(repoPath, 'build', 'azure-pipelines', 'common', 'sign-win32');
Expand Down Expand Up @@ -61,25 +61,16 @@ function packageInnoSetup(iss, options, cb) {

/**
* @param {string} arch
* @param {string} target
*/
function buildWin32Setup(arch, target) {
if (target !== 'system' && target !== 'user') {
throw new Error('Invalid setup target');
}

function buildWin32Setup(arch) {
return cb => {
const x64AppId = target === 'system' ? product.win32x64AppId : product.win32x64UserAppId;
const arm64AppId = target === 'system' ? product.win32arm64AppId : product.win32arm64UserAppId;

const sourcePath = buildPath(arch);
const outputPath = setupDir(arch, target);
const outputPath = setupDir(arch);
fs.mkdirSync(outputPath, { recursive: true });

const originalProductJsonPath = path.join(sourcePath, 'resources/app/product.json');
const productJsonPath = path.join(outputPath, 'product.json');
const productJson = JSON.parse(fs.readFileSync(originalProductJsonPath, 'utf8'));
productJson['target'] = target;
fs.writeFileSync(productJsonPath, JSON.stringify(productJson, undefined, '\t'));

const quality = product.quality || 'dev';
Expand All @@ -89,7 +80,7 @@ function buildWin32Setup(arch, target) {
DirName: product.win32DirName,
Version: pkg.version,
RawVersion: pkg.version.replace(/-\w+$/, ''),
NameVersion: product.win32NameVersion + (target === 'user' ? ' (User)' : ''),
NameVersion: product.win32NameVersion, // todo: + ' (User)'
ExeBasename: product.nameShort,
RegValueName: product.win32RegValueName,
ShellNameShort: product.win32ShellNameShort,
Expand All @@ -99,15 +90,14 @@ function buildWin32Setup(arch, target) {
TunnelApplicationName: product.tunnelApplicationName,
ApplicationName: product.applicationName,
Arch: arch,
AppId: { 'x64': x64AppId, 'arm64': arm64AppId }[arch],
IncompatibleTargetAppId: { 'x64': product.win32x64AppId, 'arm64': product.win32arm64AppId }[arch],
SystemTargetAppId: { 'x64': product.win32x64AppId, 'arm64': product.win32arm64AppId }[arch],
UserTargetAppId: { 'x64': product.win32x64UserAppId, 'arm64': product.win32arm64UserAppId }[arch],
AppUserId: product.win32AppUserModelId,
ArchitecturesAllowed: { 'x64': 'x64', 'arm64': 'arm64' }[arch],
ArchitecturesInstallIn64BitMode: { 'x64': 'x64', 'arm64': 'arm64' }[arch],
SourceDir: sourcePath,
RepoDir: repoPath,
OutputDir: outputPath,
InstallTarget: target,
ProductJsonPath: productJsonPath,
Quality: quality
};
Expand All @@ -123,17 +113,14 @@ function buildWin32Setup(arch, target) {

/**
* @param {string} arch
* @param {string} target
*/
function defineWin32SetupTasks(arch, target) {
const cleanTask = util.rimraf(setupDir(arch, target));
gulp.task(task.define(`vscode-win32-${arch}-${target}-setup`, task.series(cleanTask, buildWin32Setup(arch, target))));
function defineWin32SetupTasks(arch) {
const cleanTask = util.rimraf(setupDir(arch));
gulp.task(task.define(`vscode-win32-${arch}-setup`, task.series(cleanTask, buildWin32Setup(arch))));
}

defineWin32SetupTasks('x64', 'system');
defineWin32SetupTasks('arm64', 'system');
defineWin32SetupTasks('x64', 'user');
defineWin32SetupTasks('arm64', 'user');
defineWin32SetupTasks('x64');
defineWin32SetupTasks('arm64');

/**
* @param {string} arch
Expand Down
15 changes: 13 additions & 2 deletions build/win32/code.iss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
: '; LicenseFile: "' + RepoDir + '\' + RootLicenseFileName + '"'

[Setup]
AppId={#AppId}
UsePreviousLanguage=no
UsePreviousPrivileges=no
AppId={code:GetAppId}
AppName={#NameLong}
AppVerName={#NameVersion}
AppPublisher=Microsoft Corporation
Expand Down Expand Up @@ -1288,6 +1290,15 @@ Root: HKA; Subkey: "Software\Classes\Drive\shell\{#RegValueName}\command"; Value
Root: HKA; Subkey: "{#EnvironmentKey}"; ValueType: expandsz; ValueName: "Path"; ValueData: "{code:AddToPath|{app}\bin}"; Tasks: addtopath; Check: NeedsAddToPath(ExpandConstant('{app}\bin'))

[Code]
function GetAppId(const Value: string): string;
begin
if IsAdminInstallMode() then
Result := '{#SystemTargetAppId}'
else
Result := '{#UserTargetAppId}';
end;
function IsBackgroundUpdate(): Boolean;
begin
Result := ExpandConstant('{param:update|false}') <> 'false';
Expand Down Expand Up @@ -1321,7 +1332,7 @@ begin
#endif
if Result and not WizardSilent() then begin
RegKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + copy('{#IncompatibleTargetAppId}', 2, 38) + '_is1';
RegKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + copy('{#SystemTargetAppId}', 2, 38) + '_is1';
if RegKeyExists({#IncompatibleArchRootKey}, RegKey) then begin
if MsgBox('{#NameShort} is already installed on this system for all users. We recommend first uninstalling that version before installing this one. Are you sure you want to continue the installation?', mbConfirmation, MB_YESNO) = IDNO then begin
Expand Down
8 changes: 4 additions & 4 deletions product.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"win32DirName": "Microsoft Code OSS",
"win32NameVersion": "Microsoft Code OSS",
"win32RegValueName": "CodeOSS",
"win32x64AppId": "{{D77B7E06-80BA-4137-BCF4-654B95CCEBC5}",
"win32arm64AppId": "{{D1ACE434-89C5-48D1-88D3-E2991DF85475}",
"win32x64UserAppId": "{{CC6B787D-37A0-49E8-AE24-8559A032BE0C}",
"win32arm64UserAppId": "{{3AEBF0C8-F733-4AD4-BADE-FDB816D53D7B}",
"win32x64AppId": "{D77B7E06-80BA-4137-BCF4-654B95CCEBC5}",
"win32arm64AppId": "{D1ACE434-89C5-48D1-88D3-E2991DF85475}",
"win32x64UserAppId": "{CC6B787D-37A0-49E8-AE24-8559A032BE0C}",
"win32arm64UserAppId": "{3AEBF0C8-F733-4AD4-BADE-FDB816D53D7B}",
"win32AppUserModelId": "Microsoft.CodeOSS",
"win32ShellNameShort": "C&ode - OSS",
"win32TunnelServiceMutex": "vscodeoss-tunnelservice",
Expand Down

0 comments on commit ff5ce8a

Please sign in to comment.