Skip to content

Opening multiple instances of VS Code from Unity #152

@MattHamsay

Description

@MattHamsay

I'm running on Windows 10 and using Unity 2017.1.0.b5. I'm using 2.70-Release version of your extension that I installed from Asset Store.

Let's say I opened two instances of Unity. I click on scripts from each of the projects. I would like your extension to open two instances of VS Code where each instance is synced with a Unity project.

Currently, with my settings, it only opens one single instance of VS Code. When a script from a second project is opened, it will close the first one and switch to the next project.

I would like to have options to open multiple instances of VS Code when opened from Unity.

I looked up the list of opened & closed issues but I didn't seem to find a similar issue to my problem. I tried different settings for VSCode (I think the settings are ignored when launched from the command line) and changed a bit of Code.bin but it didn't work, although I have to admit I don't know much about the *.bin language. I tried to create a shortcut to open Code.exe with "-n" parameter but the problem for that was that I was not able to change the path to VSCode from the Preferences.VSCode panel because VS Code is installed in the default location and the path was auto detected.

Could you suggest a solution if there is a way to do this? Thanks for your helps in advance.

My settings for VS Code are as follows:

"window.openFilesInNewWindow": "on",
"window.openFoldersInNewWindow": "on",
"window.reopenFolders": "one",

I did not change anything from C:\Program Files (x86)\Microsoft VS Code\bin\Code.bin, and here is the content:

~/bin/Code.bin

@echo off
setlocal
set VSCODE_DEV=
set ELECTRON_RUN_AS_NODE=1
call "%~dp0..\Code.exe" "%~dp0..\resources\app\out\cli.js" %*
endlocal

#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

~/bin/Code

NAME="Code"
VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
ELECTRON="$VSCODE_PATH/$NAME.exe"
if grep -q Microsoft /proc/version; then
	# If running under WSL don't pass cli.js to Electron as environment vars
	# cannot be transferred from WSL to Windows
	# See: https://github.com/Microsoft/BashOnWindows/issues/1363
	#      https://github.com/Microsoft/BashOnWindows/issues/1494
	"$ELECTRON" "$@"
	exit $?
fi
if [ "$(expr substr $(uname -s) 1 9)" == "CYGWIN_NT" ]; then
	CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js")
else
	CLI="$VSCODE_PATH/resources/app/out/cli.js"
fi
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions