-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sh
executable file
·135 lines (116 loc) · 3.67 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
##########################################################################
# This is the Cake bootstrapper script for Linux and OS X.
# This version was download from https://github.com/larzw/Cake.Paket
# It was modified to use paket (instead of NuGet) for dependency management.
# Feel free to change this file to fit your needs.
##########################################################################
# Define default arguments.
SCRIPT="setup.cake"
TARGET="Default"
CONFIGURATION="Release"
VERBOSITY="verbose"
DRYRUN=
SHOW_VERSION=false
PAKET="./.paket"
CAKE="./packages/tools/Cake"
TOOLS="./packages/tools"
ADDINS="./packages/addins"
MODULES="./packages/modules"
MSBUILD=false
SCRIPT_ARGUMENTS=()
# Parse arguments.
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
-t|--target) TARGET="$2"; shift ;;
-c|--configuration) CONFIGURATION="$2"; shift ;;
-v|--verbosity) VERBOSITY="$2"; shift ;;
-d|--dryrun) DRYRUN="-dryrun" ;;
--version) SHOW_VERSION=true ;;
--paket) PAKET="$2"; shift ;;
--cake) CAKE="$2"; shift ;;
--tools) TOOLS="$2"; shift ;;
--addins) ADDINS="$2"; shift ;;
--modules) MODULES="$2"; shift ;;
--msbuild) MSBUILD=true ;;
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
*) SCRIPT_ARGUMENTS+=("$1") ;;
esac
shift
done
# Used to convert relative paths to absolute paths.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
function twoAbsolutePath {
cd ~ && cd $SCRIPT_DIR
absolutePath=$(cd $1 && pwd)
echo $absolutePath
}
PAKET_DIR=$(twoAbsolutePath $PAKET)
# Make sure the .paket directory exits.
if [ ! -d "$PAKET_DIR" ]; then
echo "Could not find .paket at '$PAKET_DIR'."
exit 1
fi
# Set paket directory enviornment variable.
export PAKET=$PAKET_DIR
# If paket.exe does not exits then download it using paket.bootstrapper.exe.
PAKET_EXE=$PAKET_DIR/paket.exe
if [ ! -f "$PAKET_EXE" ]; then
# If paket.bootstrapper.exe exits then run it.
PAKET_BOOTSTRAPPER_EXE=$PAKET_DIR/paket.bootstrapper.exe
if [ ! -f "$PAKET_BOOTSTRAPPER_EXE" ]; then
echo "Could not find paket.bootstrapper.exe at '$PAKET_BOOTSTRAPPER_EXE'."
exit 1
fi
# Download paket.exe.
mono "$PAKET_BOOTSTRAPPER_EXE"
if [ ! -f "$PAKET_EXE" ]; then
echo "Could not find paket.exe at '$PAKET_EXE'."
exit 1
fi
fi
# Find if .NET CLI is available
command -v dotnet >/dev/null 2>&1 || { MSBUILD=true; }
# Restore the dependencies.
if $MSBUILD; then
echo "Running msbuild -t:Restore Source"
msbuild -t:Restore -p:Configuration=$CONFIGURATION Source
else
echo "Running dotnet restore Source"
dotnet restore Source
fi
# tools
if [ -d "$TOOLS" ]; then
TOOLS_DIR=$(twoAbsolutePath $TOOLS)
export CAKE_PATHS_TOOLS=$TOOLS_DIR
else
echo "Could not find tools directory at '$TOOLS'."
fi
# addins
if [ -d "$ADDINS" ]; then
ADDINS_DIR=$(twoAbsolutePath $ADDINS)
export CAKE_PATHS_ADDINS=$ADDINS_DIR
else
echo "Could not find addins directory at '$ADDINS'."
fi
# modules
if [ -d "$MODULES" ]; then
MODULES_DIR=$(twoAbsolutePath $MODULES)
export CAKE_PATHS_MODULES=$MODULES_DIR
else
echo "Could not find modules directory at '$MODULES'."
fi
# Make sure that Cake has been installed.
CAKE_DIR=$(twoAbsolutePath $CAKE)
CAKE_EXE=$CAKE_DIR/Cake.exe
if [ ! -f "$CAKE_EXE" ]; then
echo "Could not find Cake.exe at '$CAKE_EXE'."
exit 1
fi
# Start Cake.
if $SHOW_VERSION; then
exec mono "$CAKE_EXE" -version
else
exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET -msbuild=$MSBUILD $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
fi