3 SCRIPT_DIR=$(dirname $(readlink -f $0))
6 SLN_NAME=dotnet-extractor/dotnet-extractor
7 TARGET_FRAMEWORK=netcoreapp3.1
8 SLN_FILE=$SCRIPT_DIR/$SLN_NAME.sln
9 OUTDIR=$SCRIPT_DIR/$SLN_NAME/bin/$CONFIGURATION/$TARGET_FRAMEWORK
10 TARGET_ASSEMBLY_DIR=/home/owner/share/.dotnet/tools
13 echo "Usage: $0 [command]"
15 echo " -b, --build Build a ExtractLine module"
16 echo " -i, --install Install assemblies to the target device"
17 echo " -c, --clean Clean all artifacts"
20 remove_intermediates() {
21 find $1 -type d \( -name bin -o -name obj \) -print0 | xargs -0 -I {} rm -fr "{}"
25 remove_intermediates $SCRIPT_DIR/$SLN_NAME
31 dotnet build -c $CONFIGURATION $SLN_FILE
37 RUNTIME_ASSEMBLIES="$OUTDIR/*.dll"
39 device_cnt=$(sdb devices | grep -v "List" | wc -l)
41 if [ $device_cnt -eq 0 ]; then
42 echo "No connected devices"
46 if [ $device_cnt -gt 1 ] && [ -z "$DEVICE_ID" ]; then
47 echo "Multiple devices are connected. Specify the device. (ex: ./build.sh --install [device-id])"
53 if [ -n "$DEVICE_ID" ]; then
54 SDB_OPTIONS="-s $DEVICE_ID"
57 sdb $SDB_OPTIONS root on
58 sdb $SDB_OPTIONS shell mount -o remount,rw /
59 sdb $SDB_OPTIONS push $RUNTIME_ASSEMBLIES $TARGET_ASSEMBLY_DIR
61 nifile_cnt=$(sdb $SDB_OPTIONS shell find $TARGET_ASSEMBLY_DIR -name 'Microsoft.DiaSymReader*.ni.dll' | wc -l)
62 if [ $nifile_cnt -gt 0 ]; then
63 sdb $SDB_OPTIONS shell "rm -f $TARGET_ASSEMBLY_DIR/Microsoft.DiaSymReader*.ni.dll"
66 #sdb $SDB_OPTIONS shell dotnettool --ni-dll $TARGET_ASSEMBLY_DIR/Microsoft.DiaSymReader*.dll
67 sdb $SDB_OPTIONS shell chsmack -a '_' $TARGET_ASSEMBLY_DIR/*.dll
68 sdb $SDB_OPTIONS shell chown owner:users $TARGET_ASSEMBLY_DIR/*.dll
69 sdb $SDB_OPTIONS shell chmod 644 $TARGET_ASSEMBLY_DIR/*.dll
72 cmd=$1; [ $# -gt 0 ] && shift;
74 build|--build|-b) build ;;
75 install|--install|-i) install $@ ;;
76 clean|--clean|-c) clean ;;