Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions build/azure-pipelines/darwin/product-build-darwin-universal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions build/gulpfile.vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`));
Expand Down
1 change: 1 addition & 0 deletions build/lib/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion resources/darwin/bin/code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion scripts/code-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 8 additions & 2 deletions scripts/code-perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '..');
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion scripts/code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion scripts/node-electron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' : ''}`);
Expand Down
27 changes: 24 additions & 3 deletions test/automation/src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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);
Comment thread
deepak1556 marked this conversation as resolved.
Comment thread
deepak1556 marked this conversation as resolved.
// 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);
Expand Down
2 changes: 1 addition & 1 deletion test/mcp/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,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)
Expand Down
6 changes: 5 additions & 1 deletion test/sanity/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,18 +785,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': {
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,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)
Expand Down
Loading