|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +show_usage() { |
| 4 | + echo "Common settings:" |
| 5 | + echo " --task <value> Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)" |
| 6 | + echo " --restore Restore dependencies" |
| 7 | + echo " --verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" |
| 8 | + echo " --help Print help and exit" |
| 9 | + echo "" |
| 10 | + echo "Command line arguments not listed above are passed thru to msbuild." |
| 11 | +} |
| 12 | + |
| 13 | +source="${BASH_SOURCE[0]}" |
| 14 | + |
| 15 | +# resolve $source until the file is no longer a symlink |
| 16 | +while [[ -h "$source" ]]; do |
| 17 | + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" |
| 18 | + source="$(readlink "$source")" |
| 19 | + # if $source was a relative symlink, we need to resolve it relative to the path where the |
| 20 | + # symlink file was located |
| 21 | + [[ $source != /* ]] && source="$scriptroot/$source" |
| 22 | +done |
| 23 | +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" |
| 24 | + |
| 25 | +Build() { |
| 26 | + local target=$1 |
| 27 | + local log_suffix="" |
| 28 | + [[ "$target" != "Execute" ]] && log_suffix=".$target" |
| 29 | + local log="$log_dir/$task$log_suffix.binlog" |
| 30 | + local output_path="$toolset_dir/$task/" |
| 31 | + |
| 32 | + MSBuild "$taskProject" \ |
| 33 | + /bl:"$log" \ |
| 34 | + /t:"$target" \ |
| 35 | + /p:Configuration="$configuration" \ |
| 36 | + /p:RepoRoot="$repo_root" \ |
| 37 | + /p:BaseIntermediateOutputPath="$output_path" \ |
| 38 | + /v:"$verbosity" \ |
| 39 | + $properties |
| 40 | +} |
| 41 | + |
| 42 | +configuration="Debug" |
| 43 | +verbosity="minimal" |
| 44 | +restore=false |
| 45 | +help=false |
| 46 | +properties='' |
| 47 | + |
| 48 | +while (($# > 0)); do |
| 49 | + lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" |
| 50 | + case $lowerI in |
| 51 | + --task) |
| 52 | + task=$2 |
| 53 | + shift 2 |
| 54 | + ;; |
| 55 | + --restore) |
| 56 | + restore=true |
| 57 | + shift 1 |
| 58 | + ;; |
| 59 | + --verbosity) |
| 60 | + verbosity=$2 |
| 61 | + shift 2 |
| 62 | + ;; |
| 63 | + --help) |
| 64 | + help=true |
| 65 | + shift 1 |
| 66 | + ;; |
| 67 | + *) |
| 68 | + properties="$properties $1" |
| 69 | + shift 1 |
| 70 | + ;; |
| 71 | + esac |
| 72 | +done |
| 73 | + |
| 74 | +ci=true |
| 75 | +binaryLog=true |
| 76 | +warnAsError=true |
| 77 | + |
| 78 | +if $help; then |
| 79 | + show_usage |
| 80 | + exit 0 |
| 81 | +fi |
| 82 | + |
| 83 | +. "$scriptroot/tools.sh" |
| 84 | +InitializeToolset |
| 85 | + |
| 86 | +if [[ -z "$task" ]]; then |
| 87 | + Write-PipelineTelemetryError -Category 'Task' -Name 'MissingTask' -Message "Missing required parameter '-task <value>'" |
| 88 | + ExitWithExitCode 1 |
| 89 | +fi |
| 90 | + |
| 91 | +taskProject=$(GetSdkTaskProject "$task") |
| 92 | +if [[ ! -e "$taskProject" ]]; then |
| 93 | + Write-PipelineTelemetryError -Category 'Task' -Name 'UnknownTask' -Message "Unknown task: $task" |
| 94 | + ExitWithExitCode 1 |
| 95 | +fi |
| 96 | + |
| 97 | +if $restore; then |
| 98 | + Build "Restore" |
| 99 | +fi |
| 100 | + |
| 101 | +Build "Execute" |
| 102 | + |
| 103 | + |
| 104 | +ExitWithExitCode 0 |
0 commit comments