Use /nuget as a default nuget source instead of nuget.org 66/274166/1
authorWonyoung Choi <wy80.choi@samsung.com>
Wed, 20 Apr 2022 06:05:24 +0000 (15:05 +0900)
committerWonyoung Choi <wy80.choi@samsung.com>
Fri, 22 Apr 2022 09:43:10 +0000 (18:43 +0900)
Change-Id: Ib2c3b48c2b6d1a045c93dd3e9a7f471a6c9c6585

tools/dotnet-wrapper.sh

index 150be97..1babad0 100755 (executable)
@@ -7,13 +7,25 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
 export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2
 export MSBUILDDISABLENODEREUSE=true
 
+# Use /nuget as a default source for NuGet packages instead of the nuget.org.
+# The public NuGet repository can not be used in GBS builds because of the network access.
+NUGET_CONFIG_FILE=$HOME/.nuget/NuGet/NuGet.Config
+if [ ! -f "$HOME/.nuget_config_fixed" ]; then
+    $DOTNET_CLI_PATH nuget disable source nuget.org --configfile $NUGET_CONFIG_FILE
+    $DOTNET_CLI_PATH nuget add source -n local /nuget --configfile $NUGET_CONFIG_FILE
+    touch $HOME/.nuget_config_fixed 2>/dev/null || true
+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" == "msbuild" -o "$CMD" == "build" -o  "$CMD" == "restore" ] ; then
   ARGS+=(/nodeReuse:false /p:UseSharedCompilation=false)
 
-  # clear nuget packages folder
+  # Clear nuget cache for each project build.
   if [ ! -f ".nuget_cache_cleared" ]; then
     $DOTNET_CLI_PATH nuget locals all --clear
     touch .nuget_cache_cleared 2>/dev/null || true