dotnet-installer/eng/common/build.sh

269 lines
6.7 KiB
Bash
Raw Normal View History

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
# 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:"
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)"
echo " --help Print help and exit (short: -h)"
2018-12-19 20:55:42 +00:00
echo ""
2018-12-19 20:55:42 +00:00
echo "Actions:"
echo " --restore Restore dependencies (short: -r)"
echo " --build Build solution (short: -b)"
echo " --sourceBuild Source-build the solution (short: -sb)"
echo " Will additionally trigger the following actions: --restore, --build, --pack"
echo " If --configuration is not set explicitly, will also set it to 'Release'"
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'"
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)"
echo " --clean Clean the solution"
2018-12-19 20:55:42 +00:00
echo ""
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"
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 ""
echo "Command line arguments not listed above are passed thru to msbuild."
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
source_build=false
vertical_build=false
product_build=false
2018-10-22 05:07:26 +00:00
rebuild=false
test=false
integration_test=false
performance_test=false
pack=false
publish=false
2018-10-22 05:07:26 +00:00
sign=false
public=false
ci=false
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
exclude_ci_binary_log=false
pipelines_log=false
2018-10-22 05:07:26 +00:00
projects=''
configuration=''
2018-10-22 05:07:26 +00:00
prepare_machine=false
verbosity='minimal'
runtime_source_feed=''
runtime_source_feed_key=''
2018-10-22 05:07:26 +00:00
properties=''
2018-12-19 20:55:42 +00:00
while [[ $# > 0 ]]; do
opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")"
2018-12-19 20:55:42 +00:00
case "$opt" in
-help|-h)
2018-12-19 20:55:42 +00:00
usage
2018-10-22 05:07:26 +00:00
exit 0
;;
-clean)
clean=true
;;
-configuration|-c)
2018-12-19 20:55:42 +00:00
configuration=$2
shift
2018-10-22 05:07:26 +00:00
;;
-verbosity|-v)
2018-12-19 20:55:42 +00:00
verbosity=$2
shift
2018-10-22 05:07:26 +00:00
;;
-binarylog|-bl)
2018-12-19 20:55:42 +00:00
binary_log=true
2018-10-22 05:07:26 +00:00
;;
-excludecibinarylog|-nobl)
exclude_ci_binary_log=true
;;
-pipelineslog|-pl)
pipelines_log=true
;;
-restore|-r)
2018-10-22 05:07:26 +00:00
restore=true
;;
-build|-b)
2018-12-19 20:55:42 +00:00
build=true
2018-10-22 05:07:26 +00:00
;;
-rebuild)
2018-12-19 20:55:42 +00:00
rebuild=true
2018-10-22 05:07:26 +00:00
;;
-pack)
2018-12-19 20:55:42 +00:00
pack=true
2018-10-22 05:07:26 +00:00
;;
-sourcebuild|-sb)
build=true
source_build=true
product_build=true
restore=true
pack=true
;;
-productBuild|-pb)
build=true
product_build=true
restore=true
pack=true
;;
-verticalbuild|-vb)
build=true
vertical_build=true
product_build=true
restore=true
pack=true
;;
-test|-t)
2018-10-22 05:07:26 +00:00
test=true
;;
-integrationtest)
2018-10-22 05:07:26 +00:00
integration_test=true
;;
-performancetest)
2018-10-22 05:07:26 +00:00
performance_test=true
2018-12-19 20:55:42 +00:00
;;
-sign)
2018-12-19 20:55:42 +00:00
sign=true
2018-10-22 05:07:26 +00:00
;;
-publish)
2018-10-22 05:07:26 +00:00
publish=true
;;
-preparemachine)
2018-12-19 20:55:42 +00:00
prepare_machine=true
;;
-projects)
2018-12-19 20:55:42 +00:00
projects=$2
shift
;;
-ci)
2018-12-19 20:55:42 +00:00
ci=true
2018-10-22 05:07:26 +00:00
;;
-warnaserror)
2018-12-19 20:55:42 +00:00
warn_as_error=$2
shift
2018-10-22 05:07:26 +00:00
;;
-nodereuse)
2018-12-19 20:55:42 +00:00
node_reuse=$2
shift
2018-10-22 05:07:26 +00:00
;;
-runtimesourcefeed)
runtime_source_feed=$2
shift
;;
-runtimesourcefeedkey)
runtime_source_feed_key=$2
shift
;;
2018-12-19 20:55:42 +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
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
pipelines_log=true
2018-12-19 20:55:42 +00:00
node_reuse=false
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 \
/p:DotNetBuildRepo=$product_build \
/p:ArcadeBuildFromSource=$source_build \
/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
}
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
if [[ "$restore" == true ]]; then
InitializeNativeTools
fi
2018-12-19 20:55:42 +00:00
Build