This repository has been archived by the owner on Jan 10, 2019. It is now read-only.
forked from tugberkugurlu/AspNetCore.Identity.MongoDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·72 lines (64 loc) · 2.11 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
#!/bin/bash
for i in "$@"
do
case $i in
-v=*|--version=*)
BUILDVERSION="${i#*=}"
shift # past argument=value
;;
-c=*|--configuration=*)
CONFIGURATION="${i#*=}"
shift # past argument=value
;;
--pack)
PACK="YES"
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
echo "BUILD VERSION = ${BUILDVERSION}"
echo "CONFIGURATION = ${CONFIGURATION}"
echo "PACK = ${PACK}"
if [ -z ${CONFIGURATION+x} ]
then
echo "No configuration is specified, defaulting to DEBUG"
CONFIGURATION=DEBUG
fi
if [ -z ${BUILDVERSION+x} ]
then
echo "No build version is specified, defaulting to 0.0.0"
BUILDVERSION=0.0.0
fi
scriptsDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
testProjectRootDirectories=(${scriptsDir%%/}/tests/*/)
dotnet restore $scriptsDir || exit 1
dotnet clean $scriptsDir --configuration $CONFIGURATION --verbosity normal || exit 1
dotnet build $scriptsDir --configuration $CONFIGURATION --verbosity normal /property:VersionPrefix=$BUILDVERSION || exit 1
for projectDirectory in "${testProjectRootDirectories[@]}"
do
projectFilePath="${projectDirectory%%/}/*.csproj"
numberOfCsprojFiles="${#projectFilePath[@]}"
if [ $numberOfCsprojFiles -eq "1" ]
then
if cat $projectFilePath | grep 'DotNetCliToolReference' | grep 'xunit' &>/dev/null
then
testDirectoryName=$(dirname "${projectFilePath}")
echo "starting to test $testDirectoryName for configration $CONFIGURATION"
(cd $testDirectoryName && dotnet xunit -nocolor -verbose -internaldiagnostics -configuration $CONFIGURATION) || exit 1
else
echo "$projectFilePath is not testable, skipping"
fi
else
echo "There are $numberOfCsprojFiles csproj file(s) for $projectFilePath, skipping testing that"
fi
done
if [ -z ${PACK+x} ]
then
echo "Pack is disabled and the pack process is skipped"
else
echo "starting to pack under $scriptsDir"
dotnet pack $scriptsDir --no-build --configuration $CONFIGURATION --verbosity normal /property:VersionPrefix=$BUILDVERSION || exit 1
fi