-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·66 lines (49 loc) · 1.74 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
#!/bin/bash
echo ""
echo "Installing dotnet cli..."
echo ""
export CURRENT_SCRIPT_DIR="$PWD/$(dirname $0)"
export DOTNET_INSTALL_DIR="$CURRENT_SCRIPT_DIR/.dotnet"
export TOOLS_DIR="$CURRENT_SCRIPT_DIR/tools"
export GET_DOTNET_SCRIPT="$TOOLS_DIR/install.sh"
echo "Download latest install script from CLI repo"
curl -L --create-dirs https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.sh -o $GET_DOTNET_SCRIPT
# Make install script executable
chmod +x $GET_DOTNET_SCRIPT
# Execute install script
$GET_DOTNET_SCRIPT --channel "preview" --version Latest --install-dir "$DOTNET_INSTALL_DIR" --no-path
origPath=$PATH
export PATH="$DOTNET_INSTALL_DIR:$PATH"
if [ $? -ne 0 ]; then
echo >&2 ".NET Execution Environment installation has failed."
exit 1
fi
export DOTNET_HOME="$DOTNET_INSTALL_DIR/cli"
export PATH="$DOTNET_HOME/bin:$PATH"
export autoGeneratedVersion=false
# Generate version number if not set
if [[ -z "$BuildSemanticVersion" ]]; then
autoVersion="$((($(date +%s) - 1451606400)/60))-$(date +%S)"
export BuildSemanticVersion="99.99.99-dev-$autoVersion"
autoGeneratedVersion=true
echo "Set version to $BuildSemanticVersion"
fi
sed -i '' "s/99.99.99-dev/$BuildSemanticVersion/g" */*/project.json
# Restore packages and build product
dotnet restore "src/dotnet-test-xunit"
dotnet pack "src/dotnet-test-xunit" --configuration Release --output "artifacts/packages"
#restore, compile, and run tests
dotnet restore "test" -s "artifacts/packages"
for test in test/*/
do
echo "Testing $test"
pushd "$test"
dotnet build
dotnet test
popd
done
sed -i '' "s/$BuildSemanticVersion/99.99.99-dev/g" */*/project.json
if [ $autoGeneratedVersion ]; then
unset BuildSemanticVersion
fi
export PATH=$origPath