forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·80 lines (67 loc) · 2.84 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
set -e
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
REPOROOT="$DIR"
DOTNET_CLI_VERSION="$(cat "$REPOROOT/DotnetCLIVersion.txt")"
CONFIGURATION="Debug"
PLATFORM="Any CPU"
args=( "$@" )
while [[ $# > 0 ]]; do
lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
-c|--configuration)
CONFIGURATION=$2
args=( "${args[@]/$1}" )
args=( "${args[@]/$2}" )
shift
;;
--platform)
PLATFORM=$2
args=( "${args[@]/$1}" )
args=( "${args[@]/$2}" )
shift
;;
--help)
echo "Usage: $0 [--configuration <CONFIGURATION>] [--platform <PLATFORM>] [--help]"
echo ""
echo "Options:"
echo " --configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
echo " --platform <PLATFORM> Skip checks for pre-reqs in dotnet_install"
echo " --help Display this help message"
exit 0
;;
*)
break
;;
esac
shift
done
# $args array may have empty elements in it.
# The easiest way to remove them is to cast to string and back to array.
# This will actually break quoted arguments, arguments like
# -test "hello world" will be broken into three arguments instead of two, as it should.
temp="${args[@]}"
args=($temp)
# Set nuget package cache under the repo
export NUGET_PACKAGES="$REPOROOT/packages"
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
[ -z "$DOTNET_INSTALL_DIR" ] && export DOTNET_INSTALL_DIR=$REPOROOT/.dotnet_cli
[ -d "$DOTNET_INSTALL_DIR" ] || mkdir -p $DOTNET_INSTALL_DIR
# Install a stage 0
DOTNET_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/dotnet/cli/feature/msbuild/scripts/obtain/dotnet-install.sh"
curl -sSL "$DOTNET_INSTALL_SCRIPT_URL" | bash /dev/stdin --version $DOTNET_CLI_VERSION --verbose
# Put stage 0 on the PATH
export PATH="$DOTNET_INSTALL_DIR:$PATH"
# Disable first run since we want to control all package sources
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
dotnet build $REPOROOT/build/build.proj /m /nologo /p:Configuration=$CONFIGURATION /p:Platform="$PLATFORM" "${args[@]}"