-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
123 lines (101 loc) · 2.86 KB
/
make.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# override commands which have pesky $path issues
find() {
"/d/Software/dev/cmder/vendor/git-for-windows/usr/bin/find.EXE" "$@"
}
7z() {
"/d/Software/disk/7-Zip/7z.exe" "$@"
}
_toLower() {
echo "$1" | tr '[:upper:]' '[:lower:]'
}
_getrid() {
if [[ "$OSTYPE" == "linux"* ]]; then
echo "linux-x64"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "osx-x64"
elif [[ "$OSTYPE" == "cygwin" ]]; then
echo "linux-x64"
elif [[ "$OSTYPE" == "msys" ]]; then
echo "win-x64"
elif [[ "$OSTYPE" == "win32" ]]; then
echo "win-x64"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
echo ""
else
echo ""
fi
}
_publishone() {
if [ -z "$1" ]; then echo "_publishone invalid rid"; exit 1; fi
if [ -z "$2" ]; then echo "_publishone invalid version"; exit 1; fi
# if [ -z "$3" ]; then echo "_publishone framework"; exit 1; fi
if [ ! -f "publish" ]; then mkdir "publish"; fi
list="make.sh.tmp.txt"
if [ -f "src/SalvageFile.csproj.orig" ]; then
mv "src/SalvageFile.csproj.orig" "src/SalvageFile.csproj"
fi
# do a restore with RID
dotnet restore -r "$1" --force-evaluate
# build regular
outNormal="bin/Normal/$1"
dotnet build -c Release -r "$1" -o "$outNormal" "src/SalvageFile.csproj"
# build standalone
outAlone="bin/Alone/$1"
dotnet publish -c Release --self-contained -r "$1" -o "$outAlone" "src/SalvageFile.csproj"
# build native - TODO currently does not support cross-compiling
outNative="bin/Native/$1"
mv "src/SalvageFile.csproj" "src/SalvageFile.csproj.orig"
cp "src/SalvageFile.csproj.native" "src/SalvageFile.csproj"
dotnet publish -c Release -r "$1" -o "$outNative" "src/SalvageFile.csproj"
mv "src/SalvageFile.csproj.orig" "src/SalvageFile.csproj"
# package regular build
find "./src/$outNormal/" -maxdepth 1 -type f > "$list"
7z a -mx=9 -ms=on -i@"$list" "./publish/$1-$2.7z"
# package standalone build
find "./src/$outAlone/" -maxdepth 1 -type f > "$list"
7z a -mx=9 -ms=on -i@"$list" "./publish/$1-standalone-$2.7z"
# package native build
find "./src/$outNative/" -maxdepth 1 -type f > "$list"
7z a -mx=9 -ms=on -i@"$list" "./publish/$1-native-$2.7z"
rm "$list"
}
# =============================================================================
test() {
dotnet test
}
debug() {
dotnet build -c "Debug"
}
release() {
dotnet build -c "Release"
}
clean() {
if [ -d "src/bin" ]; then
rm -r "src/bin";
fi
if [ -d "src/obj" ]; then
rm -r "src/obj";
fi
if [ -d "publish" ]; then
rm -r "publish";
fi
if [ -f "src/SalvageFile.csproj.orig" ]; then
mv "src/SalvageFile.csproj.orig" "src/SalvageFile.csproj"
fi
}
publish() {
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
rid="$(_getrid)"
if [ -n "$rid" ]; then
_publishone "$(_getrid)" "1.0.0" "netcoreapp2.2"
else
echo "RID '$OSTYPE' not recognized"
fi
}
if [ -z "$1" ]; then
TARGET=debug
else
TARGET=$(_toLower "$1")
fi
2>/dev/null $TARGET || (echo "Target \"$TARGET\" doesn't exist"; exit 1)