-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·64 lines (48 loc) · 1.78 KB
/
build.sh
File metadata and controls
executable file
·64 lines (48 loc) · 1.78 KB
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
#!/bin/bash -e
# Place this file in your .NET project directory. It doesn't matter where.
# Optionally include the Dockerfile. Without, the default image will be pulled from GitHub.
# Optionally include a copyTo.sh, to copy the executable to a device.
PROJECT_NAME="" #Project Name (without .csproj extension). If you leave this empty, dotnet will try to build the whole solution (and may error).
SDK="9.0"
ARCH="arm64"
OUTPUT="/bin/$ARCH"
# If Dockerfile is present, then use that. Otherwise, use image from GitHub
if [ -f "Dockerfile" ]; then
IMAGE="tinydotnet-AOT-$ARCH-$SDK"
# Check if "build" is in arguments or build-dotnet-arm64 image doesn't exist
if [[ "$*" == *"build"* ]] || ! docker images | grep -q $IMAGE; then
echo "Building Docker image..."
docker build --build-arg SDK=$SDK . -t $IMAGE
fi
else
IMAGE="ghcr.io/dottinynet/dockeraot:$ARCH-$SDK"
docker pull $IMAGE
fi
current_dir=$(pwd)
# Loop to traverse up the directory tree
while [ "$current_dir" != "/" ]; do
# Check if a .sln file exists in the current directory
sln_file=$(find "$current_dir" -maxdepth 1 -name "*.sln" | head -n 1)
if [ -n "$sln_file" ]; then
# If found, set PROJECTPATH to the directory containing the .sln file
PROJECTPATH="$current_dir"
break
fi
# Move up one directory level
current_dir=$(dirname "$current_dir")
done
if [ -n "$PROJECTPATH" ]; then
echo "Project directory found: $PROJECTPATH"
else
echo "No .sln file found in the directory tree"
exit 1
fi
set +e
OUTPUTPATH=$PROJECTPATH/$OUTPUT
OUTPUTEXE=$PROJECTPATH/$OUTPUT/$PROJECT
rm $OUTPUTEXE*
docker run --rm -it --net=host -u $(id -u):$(id -g) -v $PROJECTPATH:/src $IMAGE $PROJECT_NAME
# ----- Optional Copy
if [ -f "copyTo.sh" ]; then
source copyTo.sh $@
fi