forked from Thealexbarney/VGAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·105 lines (88 loc) · 3.2 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
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
##########################################################################
# This is the Cake bootstrapper script for Linux and OS X.
# This file was downloaded from https://github.com/cake-build/resources
# Feel free to change this file to fit your needs.
##########################################################################
# Define default arguments.
TARGET="Default"
CONFIGURATION="Release"
VERBOSITY="normal"
DRYRUN=
CLEAN=
CLEANALL=
BUILD=
TEST=
CORE=
SCRIPT_ARGUMENTS=()
# Parse arguments.
shopt -s extglob
while (($#)); do
case ${1,,} in
-t|--target) TARGET="$2"; shift ;;
-c|--configuration) CONFIGURATION="$2"; shift ;;
-v|--verbosity) VERBOSITY="$2"; shift ;;
-d|--dryrun) DRYRUN="-dryrun" ;;
@(-|--)clean) CLEAN="-clean=true" ;;
@(-|--)cleanall) CLEANALL="-cleanall=true" ;;
@(-|--)build) BUILD="-build=true" ;;
@(-|--)test) TEST="-test=true" ;;
@(-|--)netcore) CORE="-core=true" ;;
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
*) SCRIPT_ARGUMENTS+=("$1") ;;
esac
shift
done
dotnetCliVersion=$(cat DotnetCLIVersion.txt)
# Define directories.
basePath=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
buildPath=$basePath/build
dotnetPath=$basePath/tools/dotnet
dotnetCliPath=$dotnetPath/cli
globalJsonFile=$basePath/global.json
trap "rm -f $globalJsonFile" INT TERM EXIT
###########################################################################
# INSTALL .NET CORE CLI
###########################################################################
function SetupDotnetCli {
json="{\"projects\":[],\"sdk\":{\"version\":\"$dotnetCliVersion\"}}"
echo "$json" > $globalJsonFile
if command -v dotnet >/dev/null && [ "$(dotnet --version)" = $dotnetCliVersion ]; then
return
fi
homeInstallPath=~/.dotnet
path=$homeInstallPath/dotnet
if [ -f "$path" ] && [ "$("$path" --version)" = $dotnetCliVersion ]; then
export PATH="$homeInstallPath":$PATH
return
fi
path=$dotnetCliPath/dotnet
if [ -f "$path" ] && [ "$("$path" --version)" = $dotnetCliVersion ]; then
export PATH="$dotnetCliPath":$PATH
return
fi
echo "Downloading .NET Core CLI..."
bash "$dotnetPath/dotnet-install.sh" -Version $dotnetCliVersion -InstallDir "$dotnetCliPath" --no-path
if [ -f "$path" ] && [ "$("$path" --version)" = $dotnetCliVersion ]; then
export PATH="$dotnetCliPath":$PATH
return
fi
echo "Unable to locate or download .NET Core CLI version $dotnetCliVersion"
exit 1
}
# Make sure .NET Core CLI exists.
cd "$buildPath"
SetupDotnetCli
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
# Start Cake
echo "Restoring build packages..."
if ! dotnet msbuild /t:restore /v:q /nologo; then
echo "Restore for build project failed"
exit 1
fi
echo "Running build..."
dotnet publish /v:q /nologo
dotnet bin/Debug/netcoreapp2.0/publish/Build.dll --verbosity="$VERBOSITY" --configuration="$CONFIGURATION" --target="$TARGET" $DRYRUN $CLEAN $CLEANALL $BUILD $TEST $CORE "${SCRIPT_ARGUMENTS[@]}"
exit $?