forked from martincostello/project-euler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·55 lines (43 loc) · 1.47 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
#!/usr/bin/env bash
root=$(cd "$(dirname "$0")"; pwd -P)
artifacts=$root/artifacts
configuration=Release
skipTests=0
while :; do
if [ $# -le 0 ]; then
break
fi
lowerI="$(echo $1 | awk '{print tolower($0)}')"
case $lowerI in
-\?|-h|--help)
echo "./build.sh [--skip-tests] [--output <OUTPUT_DIR>]"
exit 1
;;
--output)
artifacts="$2"
shift
;;
--skip-tests)
skipTests=1
;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
;;
esac
shift
done
export CLI_VERSION=`cat ./global.json | grep -E '[0-9]\.[0-9]\.[a-zA-Z0-9\-]*' -o`
export DOTNET_INSTALL_DIR="$root/.dotnetcli"
export PATH="$DOTNET_INSTALL_DIR:$PATH"
dotnet_version=$(dotnet --version)
if [ "$dotnet_version" != "$CLI_VERSION" ]; then
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version "$CLI_VERSION" --install-dir "$DOTNET_INSTALL_DIR"
fi
dotnet build ./ProjectEuler.sln --output $artifacts --configuration $configuration || exit 1
if [ $skipTests == 0 ]; then
if [ "$TF_BUILD" != "" ]; then
dotnet test ./tests/ProjectEuler.Tests/ProjectEuler.Tests.csproj --output $artifacts --configuration $configuration --no-build --logger trx || exit 1
else
dotnet test ./tests/ProjectEuler.Tests/ProjectEuler.Tests.csproj --output $artifacts --configuration $configuration --no-build || exit 1
fi
fi