build_packages.bat.template 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. %YAML 1.2
  2. --- |
  3. @rem Copyright 2016, Google Inc.
  4. @rem All rights reserved.
  5. @rem
  6. @rem Redistribution and use in source and binary forms, with or without
  7. @rem modification, are permitted provided that the following conditions are
  8. @rem met:
  9. @rem
  10. @rem * Redistributions of source code must retain the above copyright
  11. @rem notice, this list of conditions and the following disclaimer.
  12. @rem * Redistributions in binary form must reproduce the above
  13. @rem copyright notice, this list of conditions and the following disclaimer
  14. @rem in the documentation and/or other materials provided with the
  15. @rem distribution.
  16. @rem * Neither the name of Google Inc. nor the names of its
  17. @rem contributors may be used to endorse or promote products derived from
  18. @rem this software without specific prior written permission.
  19. @rem
  20. @rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. @rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. @rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. @rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. @rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. @rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. @rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. @rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. @rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. @rem Builds gRPC NuGet packages
  32. @rem Current package versions
  33. set VERSION=${settings.csharp_version}
  34. set PROTOBUF_VERSION=3.0.0-beta2
  35. @rem Packages that depend on prerelease packages (like Google.Protobuf) need to have prerelease suffix as well.
  36. set VERSION_WITH_BETA=%VERSION%-beta
  37. @rem Adjust the location of nuget.exe
  38. set NUGET=C:\nuget\nuget.exe
  39. @rem Collect the artifacts built by the previous build step if running on Jenkins
  40. @rem TODO(jtattermusch): is there a better way to do this?
  41. xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=windows\artifacts\* Grpc.Core\windows_x86${"\\"}
  42. xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=windows\artifacts\* Grpc.Core\windows_x64${"\\"}
  43. xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=linux\artifacts\* Grpc.Core\linux_x86${"\\"}
  44. xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=linux\artifacts\* Grpc.Core\linux_x64${"\\"}
  45. xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=macos\artifacts\* Grpc.Core\macosx_x86${"\\"}
  46. xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=macos\artifacts\* Grpc.Core\macosx_x64${"\\"}
  47. @rem Collect protoc artifacts built by the previous build step
  48. xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x86${"\\"}
  49. xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x64${"\\"}
  50. xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x86${"\\"}
  51. xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x64${"\\"}
  52. xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x86${"\\"}
  53. xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x64${"\\"}
  54. @rem Fetch all dependencies
  55. %%NUGET% restore ..\..\vsprojects\grpc_csharp_ext.sln || goto :error
  56. %%NUGET% restore Grpc.sln || goto :error
  57. setlocal
  58. @call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" x86
  59. @rem We won't use the native libraries from this step, but without this Grpc.sln will fail.
  60. msbuild ..\..\vsprojects\grpc_csharp_ext.sln /p:Configuration=Release /p:PlatformToolset=v120 || goto :error
  61. msbuild Grpc.sln /p:Configuration=ReleaseSigned || goto :error
  62. endlocal
  63. %%NUGET% pack Grpc.Auth\Grpc.Auth.nuspec -Symbols -Version %VERSION% || goto :error
  64. %%NUGET% pack Grpc.Core\Grpc.Core.nuspec -Symbols -Version %VERSION% || goto :error
  65. %%NUGET% pack Grpc.HealthCheck\Grpc.HealthCheck.nuspec -Symbols -Version %VERSION_WITH_BETA% -Properties ProtobufVersion=%PROTOBUF_VERSION% || goto :error
  66. %%NUGET% pack Grpc.nuspec -Version %VERSION% || goto :error
  67. %%NUGET% pack Grpc.Tools.nuspec -Version %VERSION% || goto :error
  68. @rem copy resulting nuget packages to artifacts directory
  69. xcopy /Y /I *.nupkg ..\..\artifacts${"\\"}
  70. @rem create a zipfile with the artifacts as well
  71. powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets.zip');"
  72. xcopy /Y /I csharp_nugets.zip ..\..\artifacts${"\\"}
  73. goto :EOF
  74. :error
  75. echo Failed!
  76. exit /b %errorlevel%