grpc: Grpc.Tools 2.30 does not generate correct client code.
Doing my first grpc greeter sample (template) and following the tutorial to create a C# client. https://docs.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-3.0&tabs=visual-studio
The following code does not compile with Grpc.Tools v2.30 (Greeter.GreeterClient
does not exist)
var client = new Greeter.GreeterClient(channel);
Grpc.Tools v2.29 works fine.
HIH/2c
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (7 by maintainers)
Today I was setting up my first grpc greeter sample, too. I faced the exactly same problem like you when using the tutorial https://docs.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-3.0&tabs=visual-studio.
In step “Add greet.proto” I added the following to my project file:
As it just added a folder with a dead link to my project, I deleted the link and added the file “greet.proto” myself. This led to default file properties what leaded to missing generating of client code. Then I corrected the properties as shown in the attachment, client code gets generated as expected.
Hope this helps.
Looks like the problem was due to incorrectly setting
"GrpcServices="Server"
in<Protobuf ... />
?https://github.com/obiwanjacobi/Grpc23713/blob/afa629e6b36ac65532a844b3e8c40b31de75c942/GrpcService1/GrpcService1.csproj#L8
When that option is on, it won’t generate the client code, which seems to match what you’re seeing.
I tried the following:
GrpcServices="Server"
- changed that to Client and saved the .csproj.dotnet build Grpc23713.sln
fails. The client class was not generated.So somehow it seems to be linked to the way I add a new proto file to the client project?
Deleting the obj folder and rebuilding fixes the issue (regenerating). Hope this helps.