-
Notifications
You must be signed in to change notification settings - Fork 219
/
PublishOpenDebugAD7.sh
executable file
·135 lines (117 loc) · 3.6 KB
/
PublishOpenDebugAD7.sh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh
# Copyright (c) Microsoft. All rights reserved.
# Working dirctory to return to
__InitialCWD=$(pwd)
# Location of the script
__ScriptDirectory=
# RuntimeID to publish
__RuntimeID=
# Configuration of build
__Configuration=Debug
# OutputFolder
__OutputFolder=
log_and_exec_cmd() {
echo "##[command] $1"
$1
}
print_help()
{
echo 'PublishOpenDebugAD7.sh [-h] [-c C] [-r R]'
echo ''
echo 'This script publishes OpenDebugAD7'
echo '-h Prints usage information.'
echo '-c C The configuration to publish OpenDebugAD7. Defaults to Debug.'
echo '-r R The RuntimeID to publish OpenDebugAD7. Defaults to machine arch.'
echo '-o O Folder to output the publish. Defaults to the `dotnet publish` folder.'
}
# Gets the script directory
get_script_directory()
{
scriptDirectory=$(dirname "$0")
cd "$scriptDirectory" || fail "Command failed: 'cd \"$scriptDirectory\"'"
__ScriptDirectory=$(pwd)
cd "$__InitialCWD" || fail "Command failed: 'cd \"$__InitialCWD\"'"
}
# Parses and populates the arguments
parse_and_get_arguments()
{
while getopts "hc:r:o:" opt; do
case $opt in
c)
__Configuration=$OPTARG
;;
r)
__RuntimeID=$OPTARG
;;
o)
__OutputFolder=$OPTARG
;;
h)
print_help
exit 1
;;
:)
echo "ERROR: Option expected for -$OPTARG"
print_help
exit 1
;;
*)
print_help
exit 1
;;
esac
done
}
get_dotnet_runtime_id()
{
if [ "$(uname)" = "Darwin" ]; then
if [ "$(uname -m)" = "arm64" ]; then
__RuntimeID=osx-arm64
else
__RuntimeID=osx-x64
fi
elif [ "$(uname -m)" = "x86_64" ]; then
__RuntimeID=linux-x64
if [ -e /etc/os-release ]; then
# '.' is the same as 'source' but is POSIX compliant
. /etc/os-release
if [ "$ID" = "alpine" ]; then
__RuntimeID=linux-musl-x64
fi
fi
elif [ "$(uname -m)" = "armv7l" ]; then
__RuntimeID=linux-arm
elif [ "$(uname -m)" = "aarch64" ]; then
__RuntimeID=linux-arm64
if [ -e /etc/os-release ]; then
# '.' is the same as 'source' but is POSIX compliant
. /etc/os-release
if [ "$ID" = "alpine" ]; then
__RuntimeID=linux-musl-arm64
fi
fi
fi
}
get_script_directory
if [ -z "$1" ]; then
echo "ERROR: Missing arguments for PublishOpenDebugAD7.sh"
print_help
exit 1
else
parse_and_get_arguments "$@"
fi
if [ -z "$__RuntimeID" ]; then
get_dotnet_runtime_id
fi
echo "Info: Using Configuration '$__Configuration'"
echo "Info: Using Runtime ID '$__RuntimeID'"
__DotnetPublishArgs="-c ${__Configuration} -r ${__RuntimeID} --self-contained"
if [ -n "${__OutputFolder}" ]; then
__DotnetPublishArgs="${__DotnetPublishArgs} -o ${__OutputFolder}"
else
__OutputFolder=${__ScriptDirectory}/bin/${__Configuration}/vscode/${__RuntimeID}/publish
fi
log_and_exec_cmd "dotnet build ${__ScriptDirectory}/src/MIDebugEngine-Unix.sln -c ${__Configuration}"
log_and_exec_cmd "dotnet publish ${__ScriptDirectory}/src/OpenDebugAD7/OpenDebugAD7.csproj ${__DotnetPublishArgs}"
log_and_exec_cmd "cp ${__ScriptDirectory}/bin/${__Configuration}/Microsoft.MIDebugEngine.dll ${__OutputFolder}/."
log_and_exec_cmd "cp ${__ScriptDirectory}/bin/${__Configuration}/Microsoft.MICore.dll ${__OutputFolder}/."