-
Notifications
You must be signed in to change notification settings - Fork 824
Expand file tree
/
Copy pathstart-code.sh
More file actions
executable file
·55 lines (44 loc) · 1.71 KB
/
start-code.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# This command launches a Visual Studio Code with environment variables required to use a local version of the .NET Core SDK.
# Set VSCODE_CMD environment variable to use a different VS Code variant (e.g., code-insiders).
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# This tells .NET Core to use the same dotnet.exe that build scripts use
export DOTNET_ROOT=$DIR/.dotnet
# This tells .NET Core not to go looking for .NET Core in other places
export DOTNET_MULTILEVEL_LOOKUP=0
# Put our local dotnet on PATH first so the SDK knows which one to use
export PATH=$DOTNET_ROOT:$PATH
if [ ! -e $DOTNET_ROOT/dotnet ]; then
echo "[ERROR] .NET SDK has not yet been installed. Run ./restore.sh to install tools"
exit -1
fi
if [[ $# < 1 ]]
then
# Perform restore and build, if no args are supplied.
set -- '.';
fi
if [ -n "${VSCODE_CMD:-}" ]; then
if ! command -v "$VSCODE_CMD" &> /dev/null; then
echo "[ERROR] The specified VS Code command '$VSCODE_CMD' is not installed or cannot be found in PATH."
exit 1
fi
elif command -v code &> /dev/null && command -v code-insiders &> /dev/null; then
echo "Both 'code' and 'code-insiders' are installed."
echo " 1) code"
echo " 2) code-insiders"
read -rp "Select [1]: " choice
case "${choice:-1}" in
1) VSCODE_CMD="code" ;;
2) VSCODE_CMD="code-insiders" ;;
*) echo "[ERROR] Invalid selection."; exit 1 ;;
esac
elif command -v code &> /dev/null; then
VSCODE_CMD="code"
elif command -v code-insiders &> /dev/null; then
VSCODE_CMD="code-insiders"
else
echo "[ERROR] Neither 'code' nor 'code-insiders' is installed or can be found."
exit 1
fi
"$VSCODE_CMD" "$@"