Skip to content

Commit 4e2b20c

Browse files
author
Tajudeen
committed
fix: make windows installer target actual exe
1 parent f8c9e9a commit 4e2b20c

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

build/gulpfile.vscode.win32.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,30 @@ function buildWin32Setup(arch, target) {
7575
const outputPath = setupDir(arch, target);
7676
fs.mkdirSync(outputPath, { recursive: true });
7777

78-
// CRITICAL: Verify executable exists before creating installer
79-
const expectedExePath = path.join(sourcePath, `${product.nameShort}.exe`);
78+
// CRITICAL: Verify executable exists before creating installer.
79+
// Some upstream builds may still emit Code.exe/Void.exe instead of CortexIDE.exe.
80+
// Fall back to whatever executable actually exists so the installer launch step never breaks.
81+
let exeBasename = product.nameShort;
82+
let expectedExePath = path.join(sourcePath, `${exeBasename}.exe`);
8083
if (!fs.existsSync(expectedExePath)) {
81-
const errorMsg = `ERROR: Executable not found at expected path: ${expectedExePath}\n` +
82-
`This will cause "CreateProcess failed; code 2" error during installation.\n` +
83-
`Please verify the Windows build completed successfully and the executable was created.`;
84-
console.error(errorMsg);
85-
return cb(new Error(errorMsg));
84+
const executableCandidates = fs.readdirSync(sourcePath)
85+
.filter(file => file.toLowerCase().endsWith('.exe'))
86+
.filter(file => {
87+
const lower = file.toLowerCase();
88+
return lower !== 'inno_updater.exe' && !lower.includes('tunnel') && !lower.includes('server');
89+
});
90+
91+
if (executableCandidates.length === 0) {
92+
const errorMsg = `ERROR: Executable not found at expected path: ${expectedExePath}\n` +
93+
`and no other *.exe files were located in ${sourcePath}. ` +
94+
`This will cause "CreateProcess failed; code 2" errors during installation.`;
95+
console.error(errorMsg);
96+
return cb(new Error(errorMsg));
97+
}
98+
99+
exeBasename = path.basename(executableCandidates[0], '.exe');
100+
expectedExePath = path.join(sourcePath, `${exeBasename}.exe`);
101+
console.warn(`⚠️ ${product.nameShort}.exe not found. Using detected executable "${exeBasename}.exe" instead.`);
86102
}
87103
console.log(`✓ Executable verified: ${expectedExePath}`);
88104

@@ -93,14 +109,16 @@ function buildWin32Setup(arch, target) {
93109
fs.writeFileSync(productJsonPath, JSON.stringify(productJson, undefined, '\t'));
94110

95111
const quality = product.quality || 'dev';
112+
const dirName = product.win32DirName || product.nameShort || exeBasename;
113+
96114
const definitions = {
97115
NameLong: product.nameLong,
98116
NameShort: product.nameShort,
99-
DirName: product.win32DirName,
117+
DirName: dirName,
100118
Version: pkg.version,
101119
RawVersion: pkg.version.replace(/-\w+$/, ''),
102120
NameVersion: product.win32NameVersion + (target === 'user' ? ' (User)' : ''),
103-
ExeBasename: product.nameShort,
121+
ExeBasename: exeBasename,
104122
RegValueName: product.win32RegValueName,
105123
ShellNameShort: product.win32ShellNameShort,
106124
AppMutex: product.win32MutexName,

0 commit comments

Comments
 (0)