A script to build grpc on windows using VS2015

1,048 views
Skip to first unread message

GoldenBull Chen

unread,
Mar 22, 2016, 11:24:10 AM3/22/16
to grpc.io
I see a lot of beginners have trouble when building grpc from source code on windows. Here is my build script. Hope can help.
Before running the script:
  1. install VS2015 (2013 is ok, but you have to change several places of the script)
  2. install cmake, and make sure cmake.exe will be added into PATH
  3. download nuget.exe
  4. init all submodules
  5. change the first two lines to the directories of your nuget.exe and grpc source folder.
==================================================
@set nuget=%~dp0..\..\..\nuget\nuget.exe
@pushd ..\..\..\..\grpc
@call "%VS140COMNTOOLS%\vsvars32.bat"

@rem --------------------------------------------------------------------------------------
@title build protobuf to generate protoc.exe
pushd third_party\protobuf\cmake
cmake -G "Visual Studio 14 2015" -Dprotobuf_BUILD_TESTS=OFF . || goto :error
@rem for x64: cmake -G "Visual Studio 14 2015" -A "x64" -Dprotobuf_BUILD_TESTS=OFF . || goto :error
msbuild protobuf.sln /p:Configuration=Release /m || goto :error
msbuild protobuf.sln /p:Configuration=Debug /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build C# protobuf lib
pushd third_party\protobuf\csharp\src
%nuget% restore Google.Protobuf.sln || goto :error
msbuild Google.Protobuf.sln /p:Configuration=Debug /m || goto :error
msbuild Google.Protobuf.sln /p:Configuration=Release /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc plugins for protoc.exe
pushd vsprojects
%nuget% restore grpc_protoc_plugins.sln || goto :error
msbuild grpc_protoc_plugins.sln /p:Configuration=Release /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc C# extension x86
pushd vsprojects
%nuget% restore grpc_csharp_ext.sln || goto :error
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Debug;Platform=Win32 /m || goto :error
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Release;Platform=Win32 /m || goto :error
@title build grpc C# extension x64
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Debug;Platform=x64 /m || goto :error
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Release;Platform=x64 /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc C# lib
pushd src\csharp
%nuget% restore Grpc.sln || goto :error
msbuild Grpc.sln /p:Configuration=Debug /m || goto :error
msbuild Grpc.sln /p:Configuration=Release /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc lib
pushd vsprojects
%nuget% restore grpc.sln || goto :error
msbuild grpc.sln /p:Configuration=Debug;Platform=Win32 /t:grpc++ /m || goto :error
msbuild grpc.sln /p:Configuration=Release;Platform=Win32 /t:grpc++ /m || goto :error
msbuild grpc.sln /p:Configuration=Debug;Platform=x64 /t:grpc++ /m || goto :error
msbuild grpc.sln /p:Configuration=Release;Platform=x64 /t:grpc++ /m || goto :error
popd

@echo *************** Success! ***************
@goto :end

:error
@echo *************** Failed! ***************

:end
popd
pause

GoldenBull Chen

unread,
Mar 22, 2016, 11:25:57 AM3/22/16
to grpc.io
one more note, last step building x64 grpc lib will fail because of a bug in protobuf, which is fixed in protobuf master branch but grpc does not upgrade submodule yet.

在 2016年3月22日星期二 UTC+8下午11:24:10,GoldenBull Chen写道:

bser...@gmail.com

unread,
Jun 8, 2016, 4:01:30 PM6/8/16
to grpc.io
Hi GoldenBull,

Thanks for posting the script!
Even for "incomplete beginners", it is useful as it spares one from the need to figure out all dependencies and build order.
:-)

harerab...@gmail.com

unread,
Oct 9, 2018, 9:39:03 PM10/9/18
to grpc.io
Thanks very much, got a lot of help from this post.


在 2016年3月22日星期二 UTC+8下午11:24:10,GoldenBull Chen写道:
I see a lot of beginners have trouble when building grpc from source code on windows. Here is my build script. Hope can help.

Reply all
Reply to author
Forward
0 new messages