-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·53 lines (44 loc) · 1.49 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
#!/usr/bin/env bash
set -e
# Folder where the project is located
PROJECT="PostgresMemoryStorage"
PACKAGE="microsoft.kernelmemory.postgres"
# Move to the root of the repository
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${ROOT}"
# Clean up the build
echo "---- Cleaning up the build"
rm -f ${PROJECT}/bin/Release/*.nupkg
rm -f ${PROJECT}/bin/Release/*.snupkg
# Build only the project
echo "---- Building the project"
cd ${PROJECT}
dotnet build --no-cache --force -c Release
# Check if the nupkg has been created
echo "---- Checking if the nupkg has been created"
if [ ! -f bin/Release/*.nupkg ]; then
echo "ERROR: the nupkg file has not been created"
exit 1
fi
# Clear the cache
echo "---- Clearing the cache"
if [ -d "${HOME}/.nuget/packages/${PACKAGE}" ]; then
echo "Cache content before purge"
echo "dir: ~/.nuget/packages/${PACKAGE}"
ls -1F "${HOME}/.nuget/packages/${PACKAGE}"
rm -fR "${HOME}/.nuget/packages/${PACKAGE}"
if [ -d "${HOME}/.nuget/packages/${PACKAGE}" ]; then
echo "ERROR: unable to clear cache at ${HOME}/.nuget/packages/${PACKAGE}"
exit 1
fi
fi
# Copy the packages to the packages folder
echo "---- Copying the packages to the packages folder"
mv bin/Release/*.nupkg ${ROOT}/packages/
mv bin/Release/*.snupkg ${ROOT}/packages/
# Repo clean up
echo "---- Cleaning up the repository builds"
cd "${ROOT}"
rm -fR tests/TestApplication/bin tests/TestApplication/obj
dotnet clean --nologo -v m -c Debug
dotnet clean --nologo -v m -c Release