Updating arcade version.
This commit is contained in:
parent
584467965a
commit
c5f1e52ac4
19 changed files with 774 additions and 349 deletions
|
@ -3,35 +3,52 @@
|
|||
# Stop script if unbound variable found (use ${var:-} if intentional)
|
||||
set -u
|
||||
|
||||
ci=${ci:-false}
|
||||
configuration=${configuration:-'Debug'}
|
||||
nodereuse=${nodereuse:-true}
|
||||
prepare_machine=${prepare_machine:-false}
|
||||
restore=${restore:-true}
|
||||
verbosity=${verbosity:-'minimal'}
|
||||
warnaserror=${warnaserror:-true}
|
||||
useInstalledDotNetCli=${useInstalledDotNetCli:-true}
|
||||
# Initialize variables if they aren't already defined.
|
||||
|
||||
repo_root="$scriptroot/../.."
|
||||
eng_root="$scriptroot/.."
|
||||
artifacts_dir="$repo_root/artifacts"
|
||||
if [[ -n "${ARCADE_ARTIFACTS_DIR:-}" ]]; then
|
||||
artifacts_dir="$ARCADE_ARTIFACTS_DIR"
|
||||
export ArtifactsDir="$artifacts_dir"
|
||||
# CI mode - set to true on CI server for PR validation build or official build.
|
||||
ci=${ci:-false}
|
||||
|
||||
# Build configuration. Common values include 'Debug' and 'Release', but the repository may use other names.
|
||||
configuration=${configuration:-'Debug'}
|
||||
|
||||
# Set to true to output binary log from msbuild. Note that emitting binary log slows down the build.
|
||||
# Binary log must be enabled on CI.
|
||||
binary_log=${binary_log:-$ci}
|
||||
|
||||
# Turns on machine preparation/clean up code that changes the machine state (e.g. kills build processes).
|
||||
prepare_machine=${prepare_machine:-false}
|
||||
|
||||
# True to restore toolsets and dependencies.
|
||||
restore=${restore:-true}
|
||||
|
||||
# Adjusts msbuild verbosity level.
|
||||
verbosity=${verbosity:-'minimal'}
|
||||
|
||||
# Set to true to reuse msbuild nodes. Recommended to not reuse on CI.
|
||||
if [[ "$ci" == true ]]; then
|
||||
node_reuse=${node_reuse:-false}
|
||||
else
|
||||
node_reuse=${node_reuse:-true}
|
||||
fi
|
||||
|
||||
toolset_dir="$artifacts_dir/toolset"
|
||||
log_dir="$artifacts_dir/log/$configuration"
|
||||
temp_dir="$artifacts_dir/tmp/$configuration"
|
||||
# Configures warning treatment in msbuild.
|
||||
warn_as_error=${warn_as_error:-true}
|
||||
|
||||
global_json_file="$repo_root/global.json"
|
||||
build_driver=""
|
||||
toolset_build_proj=""
|
||||
# True to attempt using .NET Core already that meets requirements specified in global.json
|
||||
# installed on the machine instead of downloading one.
|
||||
use_installed_dotnet_cli=${use_installed_dotnet_cli:-true}
|
||||
|
||||
# True to use global NuGet cache instead of restoring packages to repository-local directory.
|
||||
if [[ "$ci" == true ]]; then
|
||||
use_global_nuget_cache=${use_global_nuget_cache:-false}
|
||||
else
|
||||
use_global_nuget_cache=${use_global_nuget_cache:-true}
|
||||
fi
|
||||
|
||||
# Resolve any symlinks in the given path.
|
||||
function ResolvePath {
|
||||
local path=$1
|
||||
|
||||
# resolve $path until the file is no longer a symlink
|
||||
while [[ -h $path ]]; do
|
||||
local dir="$( cd -P "$( dirname "$path" )" && pwd )"
|
||||
path="$(readlink "$path")"
|
||||
|
@ -62,6 +79,10 @@ function ReadGlobalVersion {
|
|||
}
|
||||
|
||||
function InitializeDotNetCli {
|
||||
if [[ -n "${_InitializeDotNetCli:-}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local install=$1
|
||||
|
||||
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
|
||||
|
@ -70,13 +91,22 @@ function InitializeDotNetCli {
|
|||
# Disable first run since we want to control all package sources
|
||||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
# Disable telemetry on CI
|
||||
if [[ $ci == true ]]; then
|
||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
fi
|
||||
|
||||
# LTTNG is the logging infrastructure used by Core CLR. Need this variable set
|
||||
# so it doesn't output warnings to the console.
|
||||
export LTTNG_HOME="$HOME"
|
||||
|
||||
# Source Build uses DotNetCoreSdkDir variable
|
||||
if [[ -n "${DotNetCoreSdkDir:-}" ]]; then
|
||||
export DOTNET_INSTALL_DIR="$DotNetCoreSdkDir"
|
||||
fi
|
||||
|
||||
# Find the first path on $PATH that contains the dotnet.exe
|
||||
if [[ "$useInstalledDotNetCli" == true && -z "${DOTNET_INSTALL_DIR:-}" ]]; then
|
||||
if [[ "$use_installed_dotnet_cli" == true && -z "${DOTNET_INSTALL_DIR:-}" ]]; then
|
||||
local dotnet_path=`command -v dotnet`
|
||||
if [[ -n "$dotnet_path" ]]; then
|
||||
ResolvePath "$dotnet_path"
|
||||
|
@ -94,10 +124,6 @@ function InitializeDotNetCli {
|
|||
dotnet_root="$DOTNET_INSTALL_DIR"
|
||||
else
|
||||
dotnet_root="$repo_root/.dotnet"
|
||||
if [[ -n "${ARCADE_DOTNET_DIR:-}" ]]; then
|
||||
dotnet_root="$ARCADE_DOTNET_DIR"
|
||||
fi
|
||||
|
||||
export DOTNET_INSTALL_DIR="$dotnet_root"
|
||||
|
||||
if [[ ! -d "$DOTNET_INSTALL_DIR/sdk/$dotnet_sdk_version" ]]; then
|
||||
|
@ -110,6 +136,10 @@ function InitializeDotNetCli {
|
|||
fi
|
||||
fi
|
||||
|
||||
# Add dotnet to PATH. This prevents any bare invocation of dotnet in custom
|
||||
# build steps from using anything other than what we've downloaded.
|
||||
export PATH="$dotnet_root:$PATH"
|
||||
|
||||
# return value
|
||||
_InitializeDotNetCli="$dotnet_root"
|
||||
}
|
||||
|
@ -152,7 +182,37 @@ function GetDotNetInstallScript {
|
|||
_GetDotNetInstallScript="$install_script"
|
||||
}
|
||||
|
||||
function InitializeBuildTool {
|
||||
if [[ -n "${_InitializeBuildTool:-}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
InitializeDotNetCli $restore
|
||||
|
||||
# return value
|
||||
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
|
||||
}
|
||||
|
||||
function GetNuGetPackageCachePath {
|
||||
if [[ -z ${NUGET_PACKAGES:-} ]]; then
|
||||
if [[ "$use_global_nuget_cache" == true ]]; then
|
||||
export NUGET_PACKAGES="$HOME/.nuget/packages"
|
||||
else
|
||||
export NUGET_PACKAGES="$repo_root/.packages"
|
||||
fi
|
||||
fi
|
||||
|
||||
# return value
|
||||
_GetNuGetPackageCachePath=$NUGET_PACKAGES
|
||||
}
|
||||
|
||||
function InitializeToolset {
|
||||
if [[ -n "${_InitializeToolset:-}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
GetNuGetPackageCachePath
|
||||
|
||||
ReadGlobalVersion "Microsoft.DotNet.Arcade.Sdk"
|
||||
|
||||
local toolset_version=$_ReadGlobalVersion
|
||||
|
@ -161,7 +221,8 @@ function InitializeToolset {
|
|||
if [[ -a "$toolset_location_file" ]]; then
|
||||
local path=`cat "$toolset_location_file"`
|
||||
if [[ -a "$path" ]]; then
|
||||
toolset_build_proj="$path"
|
||||
# return value
|
||||
_InitializeToolset="$path"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
@ -175,47 +236,17 @@ function InitializeToolset {
|
|||
local proj="$toolset_dir/restore.proj"
|
||||
|
||||
echo '<Project Sdk="Microsoft.DotNet.Arcade.Sdk"/>' > "$proj"
|
||||
MSBuild "$proj" /t:__WriteToolsetLocation /noconsolelogger /bl:"$toolset_restore_log" /p:__ToolsetLocationOutputFile="$toolset_location_file"
|
||||
|
||||
MSBuild "$proj" /t:__WriteToolsetLocation /clp:None /bl:"$toolset_restore_log" /p:__ToolsetLocationOutputFile="$toolset_location_file"
|
||||
local lastexitcode=$?
|
||||
|
||||
if [[ $lastexitcode != 0 ]]; then
|
||||
echo "Failed to restore toolset (exit code '$lastexitcode'). See log: $toolset_restore_log" >&2
|
||||
ExitWithExitCode $lastexitcode
|
||||
fi
|
||||
|
||||
toolset_build_proj=`cat "$toolset_location_file"`
|
||||
local toolset_build_proj=`cat "$toolset_location_file"`
|
||||
|
||||
if [[ ! -a "$toolset_build_proj" ]]; then
|
||||
echo "Invalid toolset path: $toolset_build_proj" >&2
|
||||
ExitWithExitCode 3
|
||||
fi
|
||||
}
|
||||
|
||||
function InitializeCustomToolset {
|
||||
local script="$eng_root/restore-toolset.sh"
|
||||
|
||||
if [[ -a "$script" ]]; then
|
||||
. "$script"
|
||||
fi
|
||||
}
|
||||
|
||||
function ConfigureTools {
|
||||
local script="$eng_root/configure-toolset.sh"
|
||||
|
||||
if [[ -a "$script" ]]; then
|
||||
. "$script"
|
||||
fi
|
||||
}
|
||||
|
||||
function InitializeTools {
|
||||
ConfigureTools
|
||||
|
||||
InitializeDotNetCli $restore
|
||||
build_driver="$_InitializeDotNetCli/dotnet"
|
||||
|
||||
InitializeToolset
|
||||
InitializeCustomToolset
|
||||
# return value
|
||||
_InitializeToolset="$toolset_build_proj"
|
||||
}
|
||||
|
||||
function ExitWithExitCode {
|
||||
|
@ -233,35 +264,57 @@ function StopProcesses {
|
|||
}
|
||||
|
||||
function MSBuild {
|
||||
if [[ "$ci" == true ]]; then
|
||||
if [[ "$binary_log" != true ]]; then
|
||||
echo "Binary log must be enabled in CI build." >&2
|
||||
ExitWithExitCode 1
|
||||
fi
|
||||
|
||||
if [[ "$node_reuse" == true ]]; then
|
||||
echo "Node reuse must be disabled in CI build." >&2
|
||||
ExitWithExitCode 1
|
||||
fi
|
||||
fi
|
||||
|
||||
InitializeBuildTool
|
||||
|
||||
local warnaserror_switch=""
|
||||
if [[ $warnaserror == true ]]; then
|
||||
if [[ $warn_as_error == true ]]; then
|
||||
warnaserror_switch="/warnaserror"
|
||||
fi
|
||||
|
||||
"$build_driver" msbuild /m /nologo /clp:Summary /v:$verbosity /nr:$nodereuse $warnaserror_switch "$@"
|
||||
"$_InitializeBuildTool" msbuild /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch /p:TreatWarningsAsErrors=$warn_as_error "$@"
|
||||
lastexitcode=$?
|
||||
|
||||
return $?
|
||||
if [[ $lastexitcode != 0 ]]; then
|
||||
echo "Build failed (exit code '$lastexitcode')." >&2
|
||||
ExitWithExitCode $lastexitcode
|
||||
fi
|
||||
}
|
||||
|
||||
ResolvePath "${BASH_SOURCE[0]}"
|
||||
_script_dir=`dirname "$_ResolvePath"`
|
||||
|
||||
eng_root=`cd -P "$_script_dir/.." && pwd`
|
||||
repo_root=`cd -P "$_script_dir/../.." && pwd`
|
||||
artifacts_dir="$repo_root/artifacts"
|
||||
toolset_dir="$artifacts_dir/toolset"
|
||||
log_dir="$artifacts_dir/log/$configuration"
|
||||
temp_dir="$artifacts_dir/tmp/$configuration"
|
||||
|
||||
global_json_file="$repo_root/global.json"
|
||||
|
||||
# HOME may not be defined in some scenarios, but it is required by NuGet
|
||||
if [[ -z $HOME ]]; then
|
||||
export HOME="$repo_root/artifacts/.home/"
|
||||
mkdir -p "$HOME"
|
||||
fi
|
||||
|
||||
if [[ -z ${NUGET_PACKAGES:-} ]]; then
|
||||
if [[ $ci == true ]]; then
|
||||
export NUGET_PACKAGES="$repo_root/.packages"
|
||||
else
|
||||
export NUGET_PACKAGES="$HOME/.nuget/packages"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$toolset_dir"
|
||||
mkdir -p "$temp_dir"
|
||||
mkdir -p "$log_dir"
|
||||
|
||||
if [[ $ci == true ]]; then
|
||||
mkdir -p "$temp_dir"
|
||||
export TEMP="$temp_dir"
|
||||
export TMP="$temp_dir"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue