|
1 | 1 | #!/usr/bin/env bash
|
2 |
| -############################################################### |
3 |
| -# This is the Cake bootstrapper script that is responsible for |
4 |
| -# downloading Cake and all specified tools from NuGet. |
5 |
| -############################################################### |
| 2 | +########################################################################## |
| 3 | +# This is the Cake bootstrapper script for Linux and OS X. |
| 4 | +# This file was downloaded from https://github.com/cake-build/resources |
| 5 | +# Feel free to change this file to fit your needs. |
| 6 | +########################################################################## |
6 | 7 |
|
7 | 8 | # Define directories.
|
8 | 9 | SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
9 | 10 | TOOLS_DIR=$SCRIPT_DIR/tools
|
10 | 11 | NUGET_EXE=$TOOLS_DIR/nuget.exe
|
11 |
| -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe |
| 12 | +NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe |
| 13 | +CAKE_VERSION=0.32.1 |
| 14 | +CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe |
| 15 | + |
| 16 | +# Temporarily skip verification of addins. |
| 17 | +export CAKE_SETTINGS_SKIPVERIFICATION='true' |
12 | 18 |
|
13 | 19 | # Define default arguments.
|
14 |
| -SCRIPT="setup.cake" |
15 | 20 | TARGET="Default"
|
16 | 21 | CONFIGURATION="Release"
|
17 | 22 | VERBOSITY="verbose"
|
18 | 23 | DRYRUN=
|
19 |
| -SHOW_VERSION=false |
20 | 24 | SCRIPT_ARGUMENTS=()
|
21 | 25 |
|
22 | 26 | # Parse arguments.
|
23 | 27 | for i in "$@"; do
|
24 | 28 | case $1 in
|
25 |
| - -s|--script) SCRIPT="$2"; shift ;; |
26 | 29 | -t|--target) TARGET="$2"; shift ;;
|
27 | 30 | -c|--configuration) CONFIGURATION="$2"; shift ;;
|
28 | 31 | -v|--verbosity) VERBOSITY="$2"; shift ;;
|
29 | 32 | -d|--dryrun) DRYRUN="-dryrun" ;;
|
30 |
| - --version) SHOW_VERSION=true ;; |
31 | 33 | --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
|
32 | 34 | *) SCRIPT_ARGUMENTS+=("$1") ;;
|
33 | 35 | esac
|
34 | 36 | shift
|
35 | 37 | done
|
36 | 38 |
|
37 | 39 | # Make sure the tools folder exist.
|
38 |
| -if [ ! -d $TOOLS_DIR ]; then |
39 |
| - mkdir $TOOLS_DIR |
| 40 | +if [ ! -d "$TOOLS_DIR" ]; then |
| 41 | + mkdir "$TOOLS_DIR" |
40 | 42 | fi
|
41 | 43 |
|
42 |
| -# Make sure that packages.config exist. |
43 |
| -if [ ! -f $TOOLS_DIR/packages.config ]; then |
44 |
| - echo "Downloading packages.config..." |
45 |
| - curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages |
46 |
| - if [ $? -ne 0 ]; then |
47 |
| - echo "An error occured while downloading packages.config." |
48 |
| - exit 1 |
49 |
| - fi |
| 44 | +########################################################################### |
| 45 | +# INSTALL .NET CORE CLI |
| 46 | +########################################################################### |
| 47 | + |
| 48 | +echo "Installing .NET CLI..." |
| 49 | +if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then |
| 50 | + mkdir "$SCRIPT_DIR/.dotnet" |
50 | 51 | fi
|
| 52 | +curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh |
| 53 | +sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.400 --install-dir .dotnet --no-path |
| 54 | +export PATH="$SCRIPT_DIR/.dotnet":$PATH |
| 55 | +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 |
| 56 | +export DOTNET_CLI_TELEMETRY_OPTOUT=1 |
| 57 | +export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 |
| 58 | +"$SCRIPT_DIR/.dotnet/dotnet" --info |
| 59 | + |
| 60 | +########################################################################### |
| 61 | +# INSTALL NUGET |
| 62 | +########################################################################### |
51 | 63 |
|
52 | 64 | # Download NuGet if it does not exist.
|
53 |
| -if [ ! -f $NUGET_EXE ]; then |
| 65 | +if [ ! -f "$NUGET_EXE" ]; then |
54 | 66 | echo "Downloading NuGet..."
|
55 |
| - curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe |
| 67 | + curl -Lsfo "$NUGET_EXE" $NUGET_URL |
56 | 68 | if [ $? -ne 0 ]; then
|
57 |
| - echo "An error occured while downloading nuget.exe." |
| 69 | + echo "An error occurred while downloading nuget.exe." |
58 | 70 | exit 1
|
59 | 71 | fi
|
60 | 72 | fi
|
61 | 73 |
|
62 |
| -# Restore tools from NuGet. |
63 |
| -pushd $TOOLS_DIR >/dev/null |
64 |
| -mono $NUGET_EXE install -ExcludeVersion -PreRelease -Source https://www.myget.org/F/cake/api/v3/index.json |
65 |
| -if [ $? -ne 0 ]; then |
66 |
| - echo "Could not restore NuGet packages." |
67 |
| - exit 1 |
| 74 | +########################################################################### |
| 75 | +# INSTALL CAKE |
| 76 | +########################################################################### |
| 77 | + |
| 78 | +if [ ! -f "$CAKE_EXE" ]; then |
| 79 | + mono "$NUGET_EXE" install Cake -Version $CAKE_VERSION -OutputDirectory "$TOOLS_DIR" |
| 80 | + if [ $? -ne 0 ]; then |
| 81 | + echo "An error occurred while installing Cake." |
| 82 | + exit 1 |
| 83 | + fi |
68 | 84 | fi
|
69 |
| -popd >/dev/null |
70 | 85 |
|
71 | 86 | # Make sure that Cake has been installed.
|
72 |
| -if [ ! -f $CAKE_EXE ]; then |
| 87 | +if [ ! -f "$CAKE_EXE" ]; then |
73 | 88 | echo "Could not find Cake.exe at '$CAKE_EXE'."
|
74 | 89 | exit 1
|
75 | 90 | fi
|
76 | 91 |
|
| 92 | +########################################################################### |
| 93 | +# RUN BUILD SCRIPT |
| 94 | +########################################################################### |
| 95 | + |
77 | 96 | # Start Cake
|
78 |
| -if $SHOW_VERSION; then |
79 |
| - exec mono $CAKE_EXE -version |
80 |
| -else |
81 |
| - exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" |
82 |
| -fi |
| 97 | +exec mono "$CAKE_EXE" setup.cake --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" |
0 commit comments