mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-14 23:18:36 +00:00
fix: rename product executable on macOS (#291948)
* fix: rename product executable name on macOS * chore: update test/automation/src/electron.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: update test/automation/src/electron.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: rename in additional places * chore: rename in code-perf.js * chore: create symlink for backwards compatibility --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -312,10 +312,10 @@ export class DarwinTestRunner extends PosixTestRunner {
|
||||
|
||||
/** @override */
|
||||
protected override async binaryPath() {
|
||||
const { nameLong } = await this.readProductJson();
|
||||
const { nameLong, nameShort } = await this.readProductJson();
|
||||
return path.join(
|
||||
this.repoLocation.uri.fsPath,
|
||||
`.build/electron/${nameLong}.app/Contents/MacOS/Electron`
|
||||
`.build/electron/${nameLong}.app/Contents/MacOS/${nameShort}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@@ -505,7 +505,7 @@
|
||||
"request": "launch",
|
||||
"name": "Run Unit Tests",
|
||||
"program": "${workspaceFolder}/test/unit/electron/index.js",
|
||||
"runtimeExecutable": "${workspaceFolder}/.build/electron/Code - OSS.app/Contents/MacOS/Electron",
|
||||
"runtimeExecutable": "${workspaceFolder}/.build/electron/Code - OSS.app/Contents/MacOS/Code - OSS",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceFolder}/.build/electron/Code - OSS.exe"
|
||||
},
|
||||
@@ -535,7 +535,7 @@
|
||||
"request": "launch",
|
||||
"name": "Run Unit Tests For Current File",
|
||||
"program": "${workspaceFolder}/test/unit/electron/index.js",
|
||||
"runtimeExecutable": "${workspaceFolder}/.build/electron/Code - OSS.app/Contents/MacOS/Electron",
|
||||
"runtimeExecutable": "${workspaceFolder}/.build/electron/Code - OSS.app/Contents/MacOS/Code - OSS",
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceFolder}/.build/electron/Code - OSS.exe"
|
||||
},
|
||||
@@ -571,7 +571,7 @@
|
||||
"timeout": 240000,
|
||||
"args": [
|
||||
"-l",
|
||||
"${workspaceFolder}/.build/electron/Code - OSS.app/Contents/MacOS/Electron"
|
||||
"${workspaceFolder}/.build/electron/Code - OSS.app/Contents/MacOS/Code - OSS"
|
||||
],
|
||||
"outFiles": [
|
||||
"${cwd}/out/**/*.js"
|
||||
|
||||
@@ -98,6 +98,20 @@ jobs:
|
||||
DEBUG=* node build/darwin/create-universal-app.ts $(agent.builddirectory)
|
||||
displayName: Create Universal App
|
||||
|
||||
- script: |
|
||||
set -e
|
||||
APP_ROOT="$(Agent.BuildDirectory)/VSCode-darwin-$(VSCODE_ARCH)"
|
||||
APP_NAME="`ls $APP_ROOT | head -n 1`"
|
||||
APP_PATH="$APP_ROOT/$APP_NAME"
|
||||
EXEC_NAME=$(node -p "require(\"$APP_PATH/Contents/Resources/app/product.json\").nameShort")
|
||||
# Create a symlink from 'Electron' to the actual executable for backward compatibility
|
||||
# This ensures apps that relied on the hardcoded path 'Contents/MacOS/Electron' continue to work
|
||||
# Remove this step once main branch is on 1.112 release.
|
||||
if [ "$EXEC_NAME" != "Electron" ] && [ ! -L "$APP_PATH/Contents/MacOS/Electron" ]; then
|
||||
ln -s "$EXEC_NAME" "$APP_PATH/Contents/MacOS/Electron"
|
||||
fi
|
||||
displayName: Create Electron symlink for backward compatibility
|
||||
|
||||
- script: |
|
||||
set -e
|
||||
APP_ROOT="$(Agent.BuildDirectory)/VSCode-darwin-$(VSCODE_ARCH)"
|
||||
|
||||
@@ -166,6 +166,21 @@ steps:
|
||||
chmod +x "$APP_PATH/Contents/Resources/app/bin/$CLI_APP_NAME"
|
||||
displayName: Make CLI executable
|
||||
|
||||
- script: |
|
||||
set -e
|
||||
APP_ROOT="$(Agent.BuildDirectory)/VSCode-darwin-$(VSCODE_ARCH)"
|
||||
APP_NAME="`ls $APP_ROOT | head -n 1`"
|
||||
APP_PATH="$APP_ROOT/$APP_NAME"
|
||||
EXEC_NAME=$(node -p "require(\"$APP_PATH/Contents/Resources/app/product.json\").nameShort")
|
||||
# Create a symlink from 'Electron' to the actual executable for backward compatibility
|
||||
# This ensures apps that relied on the hardcoded path 'Contents/MacOS/Electron' continue to work
|
||||
# Remove this step once main branch is on 1.112 release.
|
||||
if [ "$EXEC_NAME" != "Electron" ] && [ ! -L "$APP_PATH/Contents/MacOS/Electron" ]; then
|
||||
ln -s "$EXEC_NAME" "$APP_PATH/Contents/MacOS/Electron"
|
||||
fi
|
||||
condition: eq(variables['BUILT_CLIENT'], 'true')
|
||||
displayName: Create Electron symlink for backward compatibility
|
||||
|
||||
- script: |
|
||||
set -e
|
||||
APP_ROOT="$(Agent.BuildDirectory)/VSCode-darwin-$(VSCODE_ARCH)"
|
||||
|
||||
@@ -58,7 +58,9 @@ steps:
|
||||
set -e
|
||||
APP_ROOT="$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)"
|
||||
APP_NAME="`ls $APP_ROOT | head -n 1`"
|
||||
INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \
|
||||
ProductJsonPath=$(find "$APP_ROOT" -name "product.json" -type f | head -n 1)
|
||||
BINARY_NAME=$(jq -r '.nameShort' "$ProductJsonPath")
|
||||
INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/$BINARY_NAME" \
|
||||
./scripts/test-integration.sh --build --tfs "Integration Tests"
|
||||
env:
|
||||
VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH)
|
||||
@@ -77,7 +79,9 @@ steps:
|
||||
set -e
|
||||
APP_ROOT=$(agent.builddirectory)/VSCode-darwin-$(VSCODE_ARCH)
|
||||
APP_NAME="`ls $APP_ROOT | head -n 1`"
|
||||
INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \
|
||||
ProductJsonPath=$(find "$APP_ROOT" -name "product.json" -type f | head -n 1)
|
||||
BINARY_NAME=$(jq -r '.nameShort' "$ProductJsonPath")
|
||||
INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/$BINARY_NAME" \
|
||||
./scripts/test-remote-integration.sh
|
||||
env:
|
||||
VSCODE_REMOTE_SERVER_PATH: $(agent.builddirectory)/vscode-server-darwin-$(VSCODE_ARCH)
|
||||
|
||||
@@ -364,6 +364,7 @@ function packageTask(platform: string, arch: string, sourceFolderName: string, d
|
||||
} else if (platform === 'darwin') {
|
||||
const shortcut = gulp.src('resources/darwin/bin/code.sh')
|
||||
.pipe(replace('@@APPNAME@@', product.applicationName))
|
||||
.pipe(replace('@@NAME@@', product.nameShort))
|
||||
.pipe(rename('bin/code'));
|
||||
const policyDest = gulp.src('.build/policies/darwin/**', { base: '.build/policies/darwin' })
|
||||
.pipe(rename(f => f.dirname = `policies/${f.dirname}`));
|
||||
|
||||
@@ -109,6 +109,7 @@ export const config = {
|
||||
productAppName: product.nameLong,
|
||||
companyName: 'Microsoft Corporation',
|
||||
copyright: 'Copyright (C) 2026 Microsoft. All rights reserved',
|
||||
darwinExecutable: product.nameShort,
|
||||
darwinIcon: 'resources/darwin/code.icns',
|
||||
darwinBundleIdentifier: product.darwinBundleIdentifier,
|
||||
darwinApplicationCategoryType: 'public.app-category.developer-tools',
|
||||
|
||||
@@ -29,7 +29,7 @@ if [ -z "$APP_PATH" ]; then
|
||||
exit 1
|
||||
fi
|
||||
CONTENTS="$APP_PATH/Contents"
|
||||
ELECTRON="$CONTENTS/MacOS/Electron"
|
||||
ELECTRON="$CONTENTS/MacOS/@@NAME@@"
|
||||
CLI="$CONTENTS/Resources/app/out/cli.js"
|
||||
export VSCODE_NODE_OPTIONS=$NODE_OPTIONS
|
||||
export VSCODE_NODE_REPL_EXTERNAL_MODULE=$NODE_REPL_EXTERNAL_MODULE
|
||||
|
||||
@@ -12,7 +12,8 @@ function code() {
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
NAME=`node -p "require('./product.json').nameLong"`
|
||||
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
|
||||
EXE_NAME=`node -p "require('./product.json').nameShort"`
|
||||
CODE="./.build/electron/$NAME.app/Contents/MacOS/$EXE_NAME"
|
||||
else
|
||||
NAME=`node -p "require('./product.json').applicationName"`
|
||||
CODE=".build/electron/$NAME"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// @ts-check
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const perf = require('@vscode/vscode-perf');
|
||||
|
||||
const VSCODE_FOLDER = path.join(__dirname, '..');
|
||||
@@ -62,9 +63,14 @@ function getExePath(buildPath) {
|
||||
}
|
||||
let relativeExePath;
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
relativeExePath = path.join('Contents', 'MacOS', 'Electron');
|
||||
case 'darwin': {
|
||||
const product = require(path.join(buildPath, 'Contents', 'Resources', 'app', 'product.json'));
|
||||
relativeExePath = path.join('Contents', 'MacOS', product.nameShort);
|
||||
if (!fs.existsSync(path.join(buildPath, relativeExePath))) {
|
||||
relativeExePath = path.join('Contents', 'MacOS', 'Electron');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'linux': {
|
||||
const product = require(path.join(buildPath, 'resources', 'app', 'product.json'));
|
||||
relativeExePath = product.applicationName;
|
||||
|
||||
@@ -18,7 +18,8 @@ function code() {
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
NAME=`node -p "require('./product.json').nameLong"`
|
||||
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
|
||||
EXE_NAME=`node -p "require('./product.json').nameShort"`
|
||||
CODE="./.build/electron/$NAME.app/Contents/MacOS/$EXE_NAME"
|
||||
else
|
||||
NAME=`node -p "require('./product.json').applicationName"`
|
||||
CODE=".build/electron/$NAME"
|
||||
|
||||
@@ -11,7 +11,8 @@ pushd $ROOT
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
NAME=`node -p "require('./product.json').nameLong"`
|
||||
CODE="$ROOT/.build/electron/$NAME.app/Contents/MacOS/Electron"
|
||||
EXE_NAME=`node -p "require('./product.json').nameShort"`
|
||||
CODE="$ROOT/.build/electron/$NAME.app/Contents/MacOS/$EXE_NAME"
|
||||
else
|
||||
NAME=`node -p "require('./product.json').applicationName"`
|
||||
CODE="$ROOT/.build/electron/$NAME"
|
||||
|
||||
@@ -12,7 +12,8 @@ cd $ROOT
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
NAME=`node -p "require('./product.json').nameLong"`
|
||||
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
|
||||
EXE_NAME=`node -p "require('./product.json').nameShort"`
|
||||
CODE="./.build/electron/$NAME.app/Contents/MacOS/$EXE_NAME"
|
||||
else
|
||||
NAME=`node -p "require('./product.json').applicationName"`
|
||||
CODE=".build/electron/$NAME"
|
||||
|
||||
@@ -73,7 +73,7 @@ export async function main(argv: string[]): Promise<void> {
|
||||
tunnelProcess = spawn('cargo', ['run', '--', subcommand, ...tunnelArgs], { cwd: join(getAppRoot(), 'cli'), stdio, env });
|
||||
} else {
|
||||
const appPath = process.platform === 'darwin'
|
||||
// ./Contents/MacOS/Electron => ./Contents/Resources/app/bin/code-tunnel-insiders
|
||||
// ./Contents/MacOS/Code => ./Contents/Resources/app/bin/code-tunnel-insiders
|
||||
? join(dirname(dirname(process.execPath)), 'Resources', 'app')
|
||||
: dirname(process.execPath);
|
||||
const tunnelCommand = join(appPath, 'bin', `${product.tunnelApplicationName}${isWindows ? '.exe' : ''}`);
|
||||
|
||||
@@ -121,13 +121,22 @@ function findFilePath(root: string, path: string): string {
|
||||
throw new Error(`Could not find ${path} in any subdirectory`);
|
||||
}
|
||||
|
||||
function parseVersion(version: string) {
|
||||
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
|
||||
if (!match) {
|
||||
throw new Error(`Invalid version string: ${version}`);
|
||||
}
|
||||
const [, major, minor, patch] = match;
|
||||
return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
|
||||
}
|
||||
|
||||
export function getDevElectronPath(): string {
|
||||
const buildPath = join(root, '.build');
|
||||
const product = require(join(root, 'product.json'));
|
||||
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', 'Electron');
|
||||
return join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', `${product.nameShort}`);
|
||||
case 'linux':
|
||||
return join(buildPath, 'electron', `${product.applicationName}`);
|
||||
case 'win32':
|
||||
@@ -139,8 +148,20 @@ export function getDevElectronPath(): string {
|
||||
|
||||
export function getBuildElectronPath(root: string): string {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return join(root, 'Contents', 'MacOS', 'Electron');
|
||||
case 'darwin': {
|
||||
const packageJson = require(join(root, 'Contents', 'Resources', 'app', 'package.json'));
|
||||
const product = require(join(root, 'Contents', 'Resources', 'app', 'product.json'));
|
||||
const { major, minor } = parseVersion(packageJson.version);
|
||||
// For macOS builds using the legacy Electron binary name, versions up to and including
|
||||
// 1.109.x ship the executable as "Electron". From later versions onward, the executable
|
||||
// is renamed to match product.nameShort. This check preserves compatibility with older
|
||||
// builds; update the cutoff here only if the binary naming scheme changes again.
|
||||
if (major === 1 && minor <= 109) {
|
||||
return join(root, 'Contents', 'MacOS', 'Electron');
|
||||
} else {
|
||||
return join(root, 'Contents', 'MacOS', product.nameShort);
|
||||
}
|
||||
}
|
||||
case 'linux': {
|
||||
const product = require(join(root, 'resources', 'app', 'product.json'));
|
||||
return join(root, product.applicationName);
|
||||
|
||||
@@ -196,7 +196,7 @@ async function ensureStableCode(): Promise<void> {
|
||||
}));
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
// Visual Studio Code.app/Contents/MacOS/Electron
|
||||
// Visual Studio Code.app/Contents/MacOS/Code
|
||||
stableCodePath = path.dirname(path.dirname(path.dirname(stableCodeExecutable)));
|
||||
} else {
|
||||
// VSCode/Code.exe (Windows) | VSCode/code (Linux)
|
||||
|
||||
@@ -779,18 +779,22 @@ export class TestContext {
|
||||
switch (os.platform()) {
|
||||
case 'darwin': {
|
||||
let appName: string;
|
||||
let binaryName: string;
|
||||
switch (this.options.quality) {
|
||||
case 'stable':
|
||||
appName = 'Visual Studio Code.app';
|
||||
binaryName = 'Code';
|
||||
break;
|
||||
case 'insider':
|
||||
appName = 'Visual Studio Code - Insiders.app';
|
||||
binaryName = 'Code - Insiders';
|
||||
break;
|
||||
case 'exploration':
|
||||
appName = 'Visual Studio Code - Exploration.app';
|
||||
binaryName = 'Code - Exploration';
|
||||
break;
|
||||
}
|
||||
filePath = path.join(dir, appName, 'Contents/MacOS/Electron');
|
||||
filePath = path.join(dir, appName, 'Contents/MacOS', binaryName);
|
||||
break;
|
||||
}
|
||||
case 'linux': {
|
||||
|
||||
@@ -322,7 +322,7 @@ async function ensureStableCode(): Promise<void> {
|
||||
});
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
// Visual Studio Code.app/Contents/MacOS/Electron
|
||||
// Visual Studio Code.app/Contents/MacOS/Code
|
||||
stableCodePath = path.dirname(path.dirname(path.dirname(stableCodeExecutable)));
|
||||
} else {
|
||||
// VSCode/Code.exe (Windows) | VSCode/code (Linux)
|
||||
|
||||
Reference in New Issue
Block a user