From 874aec02b45dd3c3a8e8ae6c158ead268cbc1d47 Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Wed, 7 Oct 2015 19:26:19 -0700
Subject: [PATCH] move nuget restore into prebuild step on windows

---
 tools/jenkins/run_jenkins.sh         |  4 ----
 tools/run_tests/pre_build_c.bat      | 21 +++++++++++++++++++++
 tools/run_tests/pre_build_csharp.bat | 22 ++++++++++++++++++++++
 tools/run_tests/run_tests.py         |  7 +++++--
 4 files changed, 48 insertions(+), 6 deletions(-)
 create mode 100644 tools/run_tests/pre_build_c.bat
 create mode 100644 tools/run_tests/pre_build_csharp.bat

diff --git a/tools/jenkins/run_jenkins.sh b/tools/jenkins/run_jenkins.sh
index f79e739f6a..67cfc2bb0a 100755
--- a/tools/jenkins/run_jenkins.sh
+++ b/tools/jenkins/run_jenkins.sh
@@ -63,10 +63,6 @@ then
   # Prevent msbuild from picking up "platform" env variable, which would break the build
   unset platform
 
-  # TODO(jtattermusch): integrate nuget restore in a nicer way.
-  /cygdrive/c/nuget/nuget.exe restore vsprojects/grpc.sln
-  /cygdrive/c/nuget/nuget.exe restore src/csharp/Grpc.sln
-
   python tools/run_tests/run_tests.py -t -l $language -x report.xml $@ || true
 
 elif [ "$platform" == "macos" ]
diff --git a/tools/run_tests/pre_build_c.bat b/tools/run_tests/pre_build_c.bat
new file mode 100644
index 0000000000..ac8a375ad7
--- /dev/null
+++ b/tools/run_tests/pre_build_c.bat
@@ -0,0 +1,21 @@
+@rem Performs nuget restore step for C/C++.
+
+setlocal
+
+@rem enter repo root
+cd /d %~dp0\..\..
+
+@rem Location of nuget.exe
+set NUGET=C:\nuget\nuget.exe
+
+if exists %NUGET% (
+  %NUGET% restore vsprojects/grpc.sln || goto :error
+)
+
+endlocal
+
+goto :EOF
+
+:error
+echo Failed!
+exit /b %errorlevel%
diff --git a/tools/run_tests/pre_build_csharp.bat b/tools/run_tests/pre_build_csharp.bat
new file mode 100644
index 0000000000..f5890c2743
--- /dev/null
+++ b/tools/run_tests/pre_build_csharp.bat
@@ -0,0 +1,22 @@
+@rem Performs nuget restore step for C#.
+
+setlocal
+
+@rem enter repo root
+cd /d %~dp0\..\..
+
+@rem Location of nuget.exe
+set NUGET=C:\nuget\nuget.exe
+
+if exists %NUGET% (
+  %NUGET% restore vsprojects/grpc_csharp_ext.sln || goto :error
+  %NUGET% restore src/csharp/Grpc.sln || goto :error
+)
+
+endlocal
+
+goto :EOF
+
+:error
+echo Failed!
+exit /b %errorlevel%
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 69a480ac85..d5036d55d8 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -167,7 +167,10 @@ class CLanguage(object):
     return ['buildtests_%s' % self.make_target, 'tools_%s' % self.make_target]
 
   def pre_build_steps(self):
-    return []
+    if self.platform == 'windows':
+      return [['tools\\run_tests\\pre_build_c.bat']]
+    else:
+      return []
 
   def build_steps(self):
     return []
@@ -322,7 +325,7 @@ class CSharpLanguage(object):
 
   def pre_build_steps(self):
     if self.platform == 'windows':
-      return []
+      return [['tools\\run_tests\\pre_build_csharp.bat']]
     else:
       return [['tools/run_tests/pre_build_csharp.sh']]
 
-- 
GitLab