Update dependencies from https://github.com/dotnet/arcade build 20191011.1
[mono-project.git] / eng / common / build.sh
blobcc6a2fadbb5ec0a68554267395cc6854a0f1a5cf
1 #!/usr/bin/env bash
3 # Stop script if unbound variable found (use ${var:-} if intentional)
4 set -u
6 # Stop script if command returns non-zero exit code.
7 # Prevents hidden errors caused by missing error code propagation.
8 set -e
10 usage()
12 echo "Common settings:"
13 echo " --configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
14 echo " --verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)"
15 echo " --binaryLog Create MSBuild binary log (short: -bl)"
16 echo " --help Print help and exit (short: -h)"
17 echo ""
19 echo "Actions:"
20 echo " --restore Restore dependencies (short: -r)"
21 echo " --build Build solution (short: -b)"
22 echo " --rebuild Rebuild solution"
23 echo " --test Run all unit tests in the solution (short: -t)"
24 echo " --integrationTest Run all integration tests in the solution"
25 echo " --performanceTest Run all performance tests in the solution"
26 echo " --pack Package build outputs into NuGet packages and Willow components"
27 echo " --sign Sign build outputs"
28 echo " --publish Publish artifacts (e.g. symbols)"
29 echo ""
31 echo "Advanced settings:"
32 echo " --projects <value> Project or solution file(s) to build"
33 echo " --ci Set when running on CI server"
34 echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
35 echo " --nodeReuse <value> Sets nodereuse msbuild parameter ('true' or 'false')"
36 echo " --warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
37 echo ""
38 echo "Command line arguments not listed above are passed thru to msbuild."
39 echo "Arguments can also be passed in with a single hyphen."
42 source="${BASH_SOURCE[0]}"
44 # resolve $source until the file is no longer a symlink
45 while [[ -h "$source" ]]; do
46 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
47 source="$(readlink "$source")"
48 # if $source was a relative symlink, we need to resolve it relative to the path where the
49 # symlink file was located
50 [[ $source != /* ]] && source="$scriptroot/$source"
51 done
52 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
54 restore=false
55 build=false
56 rebuild=false
57 test=false
58 integration_test=false
59 performance_test=false
60 pack=false
61 publish=false
62 sign=false
63 public=false
64 ci=false
66 warn_as_error=true
67 node_reuse=true
68 binary_log=false
69 pipelines_log=false
71 projects=''
72 configuration='Debug'
73 prepare_machine=false
74 verbosity='minimal'
76 properties=''
78 while [[ $# > 0 ]]; do
79 opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
80 case "$opt" in
81 -help|-h)
82 usage
83 exit 0
85 -configuration|-c)
86 configuration=$2
87 shift
89 -verbosity|-v)
90 verbosity=$2
91 shift
93 -binarylog|-bl)
94 binary_log=true
96 -pipelineslog|-pl)
97 pipelines_log=true
99 -restore|-r)
100 restore=true
102 -build|-b)
103 build=true
105 -rebuild)
106 rebuild=true
108 -pack)
109 pack=true
111 -test|-t)
112 test=true
114 -integrationtest)
115 integration_test=true
117 -performancetest)
118 performance_test=true
120 -sign)
121 sign=true
123 -publish)
124 publish=true
126 -preparemachine)
127 prepare_machine=true
129 -projects)
130 projects=$2
131 shift
133 -ci)
134 ci=true
136 -warnaserror)
137 warn_as_error=$2
138 shift
140 -nodereuse)
141 node_reuse=$2
142 shift
145 properties="$properties $1"
147 esac
149 shift
150 done
152 if [[ "$ci" == true ]]; then
153 pipelines_log=true
154 binary_log=true
155 node_reuse=false
158 . "$scriptroot/tools.sh"
160 function InitializeCustomToolset {
161 local script="$eng_root/restore-toolset.sh"
163 if [[ -a "$script" ]]; then
164 . "$script"
168 function Build {
169 InitializeToolset
170 InitializeCustomToolset
172 if [[ ! -z "$projects" ]]; then
173 properties="$properties /p:Projects=$projects"
176 local bl=""
177 if [[ "$binary_log" == true ]]; then
178 bl="/bl:\"$log_dir/Build.binlog\""
181 MSBuild $_InitializeToolset \
182 $bl \
183 /p:Configuration=$configuration \
184 /p:RepoRoot="$repo_root" \
185 /p:Restore=$restore \
186 /p:Build=$build \
187 /p:Rebuild=$rebuild \
188 /p:Test=$test \
189 /p:Pack=$pack \
190 /p:IntegrationTest=$integration_test \
191 /p:PerformanceTest=$performance_test \
192 /p:Sign=$sign \
193 /p:Publish=$publish \
194 $properties
196 ExitWithExitCode 0
199 if [[ "$restore" == true && -z ${DisableNativeToolsetInstalls:-} ]]; then
200 InitializeNativeTools
203 Build