-
Notifications
You must be signed in to change notification settings - Fork 132
/
build.sh
executable file
·112 lines (100 loc) · 3.86 KB
/
build.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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
usage() {
echo "usage: $0 [options]"
echo "options:"
echo " -test run supported individal repo unit tests"
echo " --run-smoke-test run smoke tests"
echo " --publish-prebuilt-report publish prebuilt report data to Azure Storage"
echo " --generate-prebuilt-data generate prebuilt burndown data"
echo " --with-sdk <dir> use the SDK in the specified directory for bootstrapping"
echo "extra arguments will be passed to MSBuild"
echo ""
}
# resolve $SOURCE until the file is no longer a symlink
source="${BASH_SOURCE[0]}"
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
if [ -z "${HOME:-}" ]; then
export HOME="$scriptroot/.home"
mkdir "$HOME"
fi
if grep -q '\(/docker/\|/docker-\)' "/proc/1/cgroup"; then
export DotNetRunningInDocker=1
fi
alternateTarget=false
CUSTOM_SDK_DIR=''
for arg do
shift
opt="$(echo "$arg" | awk '{print tolower($0)}')"
case $opt in
(-test) set -- "$@" "/t:RunTests"
alternateTarget=true
;;
(--run-smoke-test) set -- "$@" "/t:RunSmokeTest"
alternateTarget=true
;;
(--publish-prebuilt-report) set -- "$@" "/t:PublishPrebuiltReportData"
alternateTarget=true
;;
(--generate-prebuilt-data) set -- "$@" "/t:GeneratePrebuiltBurndownData"
alternateTarget=true
;;
(--with-sdk)
CUSTOM_SDK_DIR="$(cd -P "$1" && pwd)"
if [ ! -d "$CUSTOM_SDK_DIR" ]; then
echo "Custom SDK directory '$CUSTOM_SDK_DIR' does not exist"
exit 1
fi
if [ ! -x "$CUSTOM_SDK_DIR/dotnet" ]; then
echo "Custom SDK '$CUSTOM_SDK_DIR/dotnet' does not exist or is not executable"
exit 1
fi
shift
;;
(*) set -- "$@" "$arg" ;;
esac
done
arcadeLine=`grep -m 1 'Microsoft\.DotNet\.Arcade\.Sdk' "$scriptroot/global.json"`
sdkLine=`grep -m 1 'dotnet' "$scriptroot/global.json"`
arcadePattern="\"Microsoft\.DotNet\.Arcade\.Sdk\" *: *\"(.*)\""
sdkPattern="\"dotnet\" *: *\"(.*)\""
if [[ $arcadeLine =~ $arcadePattern ]]; then
export ARCADE_BOOTSTRAP_VERSION=${BASH_REMATCH[1]}
fi
if [ -d "$CUSTOM_SDK_DIR" ]; then
export SDK_VERSION=`"$CUSTOM_SDK_DIR/dotnet" --version`
echo "Using custom bootstrap SDK from '$CUSTOM_SDK_DIR', version $SDK_VERSION"
CLIPATH="$CUSTOM_SDK_DIR"
SDKPATH="$CLIPATH/sdk/$SDK_VERSION"
export _InitializeDotNetCli="$CLIPATH"
export CustomDotNetSdkDir="$CLIPATH"
else
if [[ $sdkLine =~ $sdkPattern ]]; then
export SDK_VERSION=${BASH_REMATCH[1]}
CLIPATH="$scriptroot/.dotnet"
SDKPATH="$CLIPATH/sdk/$SDK_VERSION"
fi
fi
echo "Found bootstrap SDK $SDK_VERSION, bootstrap Arcade $ARCADE_BOOTSTRAP_VERSION"
if [ "$alternateTarget" == "false" ] && [[ "${SOURCE_BUILD_SKIP_SUBMODULE_CHECK:-default}" == "default" || $SOURCE_BUILD_SKIP_SUBMODULE_CHECK == "0" || $SOURCE_BUILD_SKIP_SUBMODULE_CHECK == "false" ]]; then
source "$scriptroot/check-submodules.sh"
fi
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0
export NUGET_PACKAGES="$scriptroot/packages/restored/"
set -x
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
if [ "$alternateTarget" == "true" ]; then
"$CLIPATH/dotnet" $SDKPATH/MSBuild.dll "$scriptroot/build.proj" /bl:source-build-test.binlog /flp:v=diag /clp:v=m "$@"
else
"$scriptroot/eng/common/build.sh" --restore --build -c Release --warnaserror false -bl /flp:v=diag "$@"
fi