2018-10-22 05:07:26 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
# Stop script if unbound variable found (use ${var:-} if intentional)
|
|
|
|
set -u
|
|
|
|
|
2019-01-09 13:14:18 +00:00
|
|
|
# Stop script if command returns non-zero exit code.
|
|
|
|
# Prevents hidden errors caused by missing error code propagation.
|
|
|
|
set -e
|
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "Common settings:"
|
2019-02-23 13:42:18 +00:00
|
|
|
echo " --configuration <value> Build configuration: 'Debug' or 'Release' (short: -c)"
|
2018-12-19 20:55:42 +00:00
|
|
|
echo " --verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)"
|
|
|
|
echo " --binaryLog Create MSBuild binary log (short: -bl)"
|
2019-03-01 13:11:16 +00:00
|
|
|
echo " --help Print help and exit (short: -h)"
|
2018-12-19 20:55:42 +00:00
|
|
|
echo ""
|
2019-03-01 13:11:16 +00:00
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
echo "Actions:"
|
|
|
|
echo " --restore Restore dependencies (short: -r)"
|
2019-03-01 13:11:16 +00:00
|
|
|
echo " --build Build solution (short: -b)"
|
2022-07-29 12:36:00 +00:00
|
|
|
echo " --sourceBuild Source-build the solution (short: -sb)"
|
2022-07-27 12:33:07 +00:00
|
|
|
echo " Will additionally trigger the following actions: --restore, --build, --pack"
|
|
|
|
echo " If --configuration is not set explicitly, will also set it to 'Release'"
|
2024-01-18 00:54:27 +00:00
|
|
|
echo " --productBuild Build the solution in the way it will be built in the full .NET product (VMR) build (short: -pb)"
|
|
|
|
echo " Will additionally trigger the following actions: --restore, --build, --pack"
|
|
|
|
echo " If --configuration is not set explicitly, will also set it to 'Release'"
|
2019-03-01 13:11:16 +00:00
|
|
|
echo " --rebuild Rebuild solution"
|
|
|
|
echo " --test Run all unit tests in the solution (short: -t)"
|
|
|
|
echo " --integrationTest Run all integration tests in the solution"
|
|
|
|
echo " --performanceTest Run all performance tests in the solution"
|
|
|
|
echo " --pack Package build outputs into NuGet packages and Willow components"
|
2018-12-19 20:55:42 +00:00
|
|
|
echo " --sign Sign build outputs"
|
|
|
|
echo " --publish Publish artifacts (e.g. symbols)"
|
2019-10-24 22:05:36 +00:00
|
|
|
echo " --clean Clean the solution"
|
2018-12-19 20:55:42 +00:00
|
|
|
echo ""
|
2019-03-01 13:11:16 +00:00
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
echo "Advanced settings:"
|
|
|
|
echo " --projects <value> Project or solution file(s) to build"
|
|
|
|
echo " --ci Set when running on CI server"
|
2020-05-12 12:48:04 +00:00
|
|
|
echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
|
2018-12-19 20:55:42 +00:00
|
|
|
echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
|
|
|
|
echo " --nodeReuse <value> Sets nodereuse msbuild parameter ('true' or 'false')"
|
|
|
|
echo " --warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
|
|
|
|
echo ""
|
2019-05-07 12:30:40 +00:00
|
|
|
echo "Command line arguments not listed above are passed thru to msbuild."
|
2019-03-01 13:11:16 +00:00
|
|
|
echo "Arguments can also be passed in with a single hyphen."
|
2018-12-19 20:55:42 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 05:07:26 +00:00
|
|
|
source="${BASH_SOURCE[0]}"
|
|
|
|
|
|
|
|
# resolve $source until the file is no longer a symlink
|
|
|
|
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
|
|
|
|
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
|
|
|
|
|
|
|
|
restore=false
|
|
|
|
build=false
|
2022-07-27 12:33:07 +00:00
|
|
|
source_build=false
|
2023-12-12 15:20:34 +00:00
|
|
|
vertical_build=false
|
2024-01-18 00:54:27 +00:00
|
|
|
product_build=false
|
2018-10-22 05:07:26 +00:00
|
|
|
rebuild=false
|
|
|
|
test=false
|
|
|
|
integration_test=false
|
|
|
|
performance_test=false
|
2019-03-01 13:11:16 +00:00
|
|
|
pack=false
|
|
|
|
publish=false
|
2018-10-22 05:07:26 +00:00
|
|
|
sign=false
|
|
|
|
public=false
|
|
|
|
ci=false
|
2019-10-24 22:05:36 +00:00
|
|
|
clean=false
|
2018-10-22 05:07:26 +00:00
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
warn_as_error=true
|
|
|
|
node_reuse=true
|
|
|
|
binary_log=false
|
2020-05-12 12:48:04 +00:00
|
|
|
exclude_ci_binary_log=false
|
2019-05-22 12:11:57 +00:00
|
|
|
pipelines_log=false
|
2018-10-22 05:07:26 +00:00
|
|
|
|
|
|
|
projects=''
|
2022-07-27 12:33:07 +00:00
|
|
|
configuration=''
|
2018-10-22 05:07:26 +00:00
|
|
|
prepare_machine=false
|
|
|
|
verbosity='minimal'
|
2020-08-26 13:09:20 +00:00
|
|
|
runtime_source_feed=''
|
|
|
|
runtime_source_feed_key=''
|
2019-03-01 13:11:16 +00:00
|
|
|
|
2018-10-22 05:07:26 +00:00
|
|
|
properties=''
|
2018-12-19 20:55:42 +00:00
|
|
|
while [[ $# > 0 ]]; do
|
2021-01-09 13:53:15 +00:00
|
|
|
opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")"
|
2018-12-19 20:55:42 +00:00
|
|
|
case "$opt" in
|
2019-03-01 13:11:16 +00:00
|
|
|
-help|-h)
|
2018-12-19 20:55:42 +00:00
|
|
|
usage
|
2018-10-22 05:07:26 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
2019-10-24 22:05:36 +00:00
|
|
|
-clean)
|
|
|
|
clean=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-configuration|-c)
|
2018-12-19 20:55:42 +00:00
|
|
|
configuration=$2
|
|
|
|
shift
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-verbosity|-v)
|
2018-12-19 20:55:42 +00:00
|
|
|
verbosity=$2
|
|
|
|
shift
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-binarylog|-bl)
|
2018-12-19 20:55:42 +00:00
|
|
|
binary_log=true
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2023-10-19 20:12:15 +00:00
|
|
|
-excludecibinarylog|-nobl)
|
2020-05-12 12:48:04 +00:00
|
|
|
exclude_ci_binary_log=true
|
|
|
|
;;
|
2019-05-22 12:11:57 +00:00
|
|
|
-pipelineslog|-pl)
|
|
|
|
pipelines_log=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-restore|-r)
|
2018-10-22 05:07:26 +00:00
|
|
|
restore=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-build|-b)
|
2018-12-19 20:55:42 +00:00
|
|
|
build=true
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-rebuild)
|
2018-12-19 20:55:42 +00:00
|
|
|
rebuild=true
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-pack)
|
2018-12-19 20:55:42 +00:00
|
|
|
pack=true
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2022-07-27 12:33:07 +00:00
|
|
|
-sourcebuild|-sb)
|
|
|
|
build=true
|
|
|
|
source_build=true
|
2024-01-18 00:54:27 +00:00
|
|
|
product_build=true
|
|
|
|
restore=true
|
|
|
|
pack=true
|
|
|
|
;;
|
|
|
|
-productBuild|-pb)
|
|
|
|
build=true
|
|
|
|
product_build=true
|
2022-07-27 12:33:07 +00:00
|
|
|
restore=true
|
|
|
|
pack=true
|
|
|
|
;;
|
2023-12-12 15:20:34 +00:00
|
|
|
-verticalbuild|-vb)
|
|
|
|
build=true
|
|
|
|
vertical_build=true
|
2024-01-18 00:54:27 +00:00
|
|
|
product_build=true
|
2023-12-12 15:20:34 +00:00
|
|
|
restore=true
|
|
|
|
pack=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-test|-t)
|
2018-10-22 05:07:26 +00:00
|
|
|
test=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-integrationtest)
|
2018-10-22 05:07:26 +00:00
|
|
|
integration_test=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-performancetest)
|
2018-10-22 05:07:26 +00:00
|
|
|
performance_test=true
|
2018-12-19 20:55:42 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-sign)
|
2018-12-19 20:55:42 +00:00
|
|
|
sign=true
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-publish)
|
2018-10-22 05:07:26 +00:00
|
|
|
publish=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-preparemachine)
|
2018-12-19 20:55:42 +00:00
|
|
|
prepare_machine=true
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-projects)
|
2018-12-19 20:55:42 +00:00
|
|
|
projects=$2
|
|
|
|
shift
|
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-ci)
|
2018-12-19 20:55:42 +00:00
|
|
|
ci=true
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-warnaserror)
|
2018-12-19 20:55:42 +00:00
|
|
|
warn_as_error=$2
|
|
|
|
shift
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2019-03-01 13:11:16 +00:00
|
|
|
-nodereuse)
|
2018-12-19 20:55:42 +00:00
|
|
|
node_reuse=$2
|
|
|
|
shift
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
2020-08-26 13:09:20 +00:00
|
|
|
-runtimesourcefeed)
|
|
|
|
runtime_source_feed=$2
|
|
|
|
shift
|
|
|
|
;;
|
2020-10-28 15:07:45 +00:00
|
|
|
-runtimesourcefeedkey)
|
2020-08-26 13:09:20 +00:00
|
|
|
runtime_source_feed_key=$2
|
|
|
|
shift
|
|
|
|
;;
|
2018-12-19 20:55:42 +00:00
|
|
|
*)
|
2019-05-07 12:30:40 +00:00
|
|
|
properties="$properties $1"
|
2018-10-22 05:07:26 +00:00
|
|
|
;;
|
|
|
|
esac
|
2018-12-19 20:55:42 +00:00
|
|
|
|
|
|
|
shift
|
2018-10-22 05:07:26 +00:00
|
|
|
done
|
|
|
|
|
2022-07-27 12:33:07 +00:00
|
|
|
if [[ -z "$configuration" ]]; then
|
|
|
|
if [[ "$source_build" = true ]]; then configuration="Release"; else configuration="Debug"; fi
|
|
|
|
fi
|
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
if [[ "$ci" == true ]]; then
|
2019-05-22 12:11:57 +00:00
|
|
|
pipelines_log=true
|
2018-12-19 20:55:42 +00:00
|
|
|
node_reuse=false
|
2020-05-12 12:48:04 +00:00
|
|
|
if [[ "$exclude_ci_binary_log" == false ]]; then
|
|
|
|
binary_log=true
|
|
|
|
fi
|
2018-12-19 20:55:42 +00:00
|
|
|
fi
|
|
|
|
|
2018-10-22 05:07:26 +00:00
|
|
|
. "$scriptroot/tools.sh"
|
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
function InitializeCustomToolset {
|
|
|
|
local script="$eng_root/restore-toolset.sh"
|
|
|
|
|
|
|
|
if [[ -a "$script" ]]; then
|
|
|
|
. "$script"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function Build {
|
|
|
|
InitializeToolset
|
|
|
|
InitializeCustomToolset
|
|
|
|
|
|
|
|
if [[ ! -z "$projects" ]]; then
|
|
|
|
properties="$properties /p:Projects=$projects"
|
|
|
|
fi
|
|
|
|
|
|
|
|
local bl=""
|
|
|
|
if [[ "$binary_log" == true ]]; then
|
|
|
|
bl="/bl:\"$log_dir/Build.binlog\""
|
|
|
|
fi
|
|
|
|
|
|
|
|
MSBuild $_InitializeToolset \
|
|
|
|
$bl \
|
|
|
|
/p:Configuration=$configuration \
|
|
|
|
/p:RepoRoot="$repo_root" \
|
|
|
|
/p:Restore=$restore \
|
|
|
|
/p:Build=$build \
|
2024-01-18 00:54:27 +00:00
|
|
|
/p:DotNetBuildRepo=$product_build \
|
2022-07-27 12:33:07 +00:00
|
|
|
/p:ArcadeBuildFromSource=$source_build \
|
2024-01-25 21:14:09 +00:00
|
|
|
/p:DotNetBuildSourceOnly=$source_build \
|
2023-12-12 15:20:34 +00:00
|
|
|
/p:ArcadeBuildVertical=$vertical_build \
|
2018-12-19 20:55:42 +00:00
|
|
|
/p:Rebuild=$rebuild \
|
|
|
|
/p:Test=$test \
|
|
|
|
/p:Pack=$pack \
|
|
|
|
/p:IntegrationTest=$integration_test \
|
|
|
|
/p:PerformanceTest=$performance_test \
|
|
|
|
/p:Sign=$sign \
|
|
|
|
/p:Publish=$publish \
|
|
|
|
$properties
|
|
|
|
|
|
|
|
ExitWithExitCode 0
|
|
|
|
}
|
|
|
|
|
2019-10-24 22:05:36 +00:00
|
|
|
if [[ "$clean" == true ]]; then
|
|
|
|
if [ -d "$artifacts_dir" ]; then
|
|
|
|
rm -rf $artifacts_dir
|
|
|
|
echo "Artifacts directory deleted."
|
|
|
|
fi
|
|
|
|
exit 0
|
2018-10-22 05:07:26 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-24 22:05:36 +00:00
|
|
|
if [[ "$restore" == true ]]; then
|
2019-05-02 12:26:55 +00:00
|
|
|
InitializeNativeTools
|
|
|
|
fi
|
|
|
|
|
2018-12-19 20:55:42 +00:00
|
|
|
Build
|