Add restore option in dotnet-wrapper 10/285510/1
authorj-h.choi <j-h.choi@samsung.com>
Wed, 14 Dec 2022 02:50:08 +0000 (11:50 +0900)
committerj-h.choi <j-h.choi@samsung.com>
Wed, 14 Dec 2022 02:50:50 +0000 (11:50 +0900)
Change-Id: I93df540435a4eadbee65d777d618ed30d7a27bf0

tools/dotnet-wrapper.sh

index 34aeab6..d632fad 100755 (executable)
@@ -23,7 +23,22 @@ fi
 # This is a workaround for the relative path issue in dotnet-cli.
 # https://github.com/NuGet/Home/issues/9406
 CMD=$1; shift
-ARGS=("$@")
+if [ "$CMD" == "restore" ]; then
+  while [[ $# -gt 0 ]]; do
+    x="$1"
+    if [ "$x" == "-s" -o "$x" == "--source" ]; then
+      ARGS+=($x $(readlink -m $2))
+      shift
+    elif [[ "$x" =~ --source=(.+) ]]; then
+      ARGS+=(--source=$(readlink -m $(eval echo ${BASH_REMATCH[1]})))
+    else
+      ARGS+=("$x")
+    fi
+    shift
+  done
+else
+  ARGS=("$@")
+fi
 
 
 if [ "$CMD" == "msbuild" -o "$CMD" == "build" -o  "$CMD" == "restore" ] ; then
@@ -31,7 +46,7 @@ if [ "$CMD" == "msbuild" -o "$CMD" == "build" -o  "$CMD" == "restore" ] ; then
 
   # Clear nuget cache for each project build.
   if [ ! -f ".nuget_cache_cleared" ]; then
-    $DOTNET_CLI_PATH nuget locals all --clear
+    rm -rf $HOME/.nuget/packages/*
     touch .nuget_cache_cleared 2>/dev/null || true
   fi
 fi