forked from dotnet/corefxlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·102 lines (87 loc) · 2.44 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
#!/usr/bin/env bash
# adding dotnet to the path. it is needed to run toolset csc.
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
dotnet_path=$parent_path/dotnet
export PATH=$PATH:$dotnet_path
usage()
{
echo "build.sh [ Debug(default) | Release ]"
}
if [ "$1" == "-?" ] || [ "$1" == "-h" ]; then
usage
exit
fi
if [ $# -eq 0 ]
then
Configuration="Debug"
else
Configuration=$1
fi
BuildVersion="e$(date '+%y%m%d')-1"
Version="<default>"
Restore="true"
echo "Configuration=$Configuration."
echo "Restore=$Restore."
echo "Version=$Version."
echo "BuildVersion=$BuildVersion."
if [ ! -d "dotnet" ]; then
echo "dotnet.exe not installed, downloading and installing."
if [ "$Version" = "<default>" ]; then
Version=$(head -n 1 "DotnetCLIVersion.txt")
fi
./scripts/install-dotnet.sh -Version $Version -InstallDir "dotnet"
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to install latest dotnet.exe, exit code "$ret", aborting build."
exit -1
fi
./scripts/install-dotnet.sh -Version 1.0.0 -InstallDir "dotnet"
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to install framework version 1.0.0, exit code "$ret", aborting build."
exit -1
fi
fi
dotnetExePath="dotnet/dotnet"
myFile="corefxlab.sln"
if [ "$Restore" = "true" ]; then
echo "Restoring all packages"
./$dotnetExePath restore $myFile /p:VersionSuffix=$BuildVersion
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to restore packages."
exit -1
fi
fi
echo "Building solution $myFile..."
./$dotnetExePath build $myFile -c $Configuration /p:VersionSuffix=$BuildVersion
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to build solution $myFile"
exit -1
fi
errorsEncountered=0
declare -a projectsFailed
while read testFile;
do
echo "Building and running tests for project $testFile..."
./$dotnetExePath test $testFile -c $Configuration --no-build -- -notrait category=performance -notrait category=outerloop
ret=$?
if [ $ret -ne 0 ]; then
echo "Some tests failed in project $testFile"
projectsFailed[${#projectsFailed[@]}]="$testFile"
((errorsEncountered=errorsEncountered+1))
fi
done < <(find tests -name "*.csproj")
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
if [ $errorsEncountered -ne 0 ]; then
echo -e "${RED}** Build failed. $errorsEncountered projects failed to build or test. **${NC}"
for i in "${projectsFailed[@]}"
do
echo -e "${RED} $i${NC}"
done
else
echo -e "${GREEN}** Build succeeded. **${NC}"
fi