forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·95 lines (78 loc) · 3.5 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/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"
export NUGET_HTTP_CACHE_PATH="$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
# NuGet depends on HOME and it may not be set. Until it's fixed, we just patch a value in
if [ -z "$HOME" ]; then
export HOME="$REPOROOT/.home"
[ ! -d "$HOME" ] || rm -Rf $HOME
mkdir -p $HOME
fi
# Install a stage 0
DOTNET_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh"
curl -sSL "$DOTNET_INSTALL_SCRIPT_URL" | bash /dev/stdin --version $DOTNET_CLI_VERSION --verbose
# Install 1.0.4 shared framework
[ -d "$DOTNET_INSTALL_DIR/shared/Microsoft.NETCore.App/1.0.4" ] || curl -sSL "$DOTNET_INSTALL_SCRIPT_URL" | bash /dev/stdin --channel "Preview" --version "1.0.4" --shared-runtime
# Install 1.1.1 shared framework
[ -d "$DOTNET_INSTALL_DIR/shared/Microsoft.NETCore.App/1.1.1" ] || curl -sSL "$DOTNET_INSTALL_SCRIPT_URL" | bash /dev/stdin --channel "Release/1.1.0" --version "1.1.1" --shared-runtime
# 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 msbuild $REPOROOT/build/build.proj /m:1 /nologo /p:Configuration=$CONFIGURATION /p:Platform="$PLATFORM" "${args[@]}"