Visual Studio automatically compiles settings for GRPC projects

Source: Internet
Author: User

Tags: CLI project Configure RPC Auto-compilation for modify script TOC

Some time ago to study a Java program, add some features. The communication between Java and C # is used. Naturally, there are a number of ways to actually implement the rest WCF service that calls C # with JavaScript. But in the process of checking information, found that there is a protocol buffers, Google developed, can also be used. Out of curiosity, tried it. Java compiles with Maven, C #, which can be compiled with MSBuild, but requires some configuration.

Suppose the project has these files: Test.proto,testclient.cs (call GRPC client), want to click on the F5 to compile well, how to do it?

1. Download and install the NuGet package: Grpc,, Grpc.Tools.MSBuild.Unofficial, google.protobuf (Note that There's a google.protocolbuffers bag, don't mix it up.

2. Modify the Grpc.Tools.MsBuild.Unofficial.props file to change the value of grpctoolsversion to the value actually used (currently the latest version is 1.15.0)

3. Modify the Grpc.Tools.MsBuild.Unofficial.targets file

1) Change the value of _grpcoutputfolder to $ (intermediateoutputpath) Of course, change to another value is OK, but if the directory does not exist need to add a build directory process, more trouble. $ (IntermediateOutputPath) location is Obj\debug, the system is the default, it is more convenient, put in this place is more appropriate

2) Change the value of Grpctoolspath to $ (msbuildthisfiledirectory). \.. \$ (grpctoolsversion) \tools\, the original path is wrong, compile error.

3) Change the value of the property beforetargets after <target name= "Generategrpcfiles" to Prepareforbuild

4. Modify the project file, assuming the file name is testgrpc.csproj:

1) the

<import project= ". \packages\\build\ "Condition=" Exists (' .. \packages\\build\ ') "/> This line moves to

<import project= ". \packages\grpc.core.1.15.0\build\net45\grpc.core.targets "condition=" Exists ('.. \packages\grpc.core.1.15.0\build\net45\grpc.core.targets ') "in the back row of the/>

2) Move the <import project= "$ (MSBuildToolsPath) \microsoft.csharp.targets"/> To the last line of <Target>

Now, press F5, and you'll compile it one step at a time.

Visual Studio automatically compiles settings for GRPC projects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: