无需CSPROJ生成dotnet grpc客户端代码
可以使用ProtoC
以不需要CSPROJ或解决方案的方式生成dotnet代码:
protoc -I=$SRC_DIR --csharp_out=$DST_DIR $SRC_DIR/addressbook.proto
是否可以执行类似的操作以生成GRPC客户端/服务器存根的代码?
It's possible to use protoc
to generate dotnet code in a way that doesn't require a csproj or solution:
protoc -I=$SRC_DIR --csharp_out=$DST_DIR $SRC_DIR/addressbook.proto
Is it possible to do something similar to generate the code for a grpc client/server stub?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的 - 您只需要GRPC插件,您可以在
grpc.tools
软件包中下载。然后使用:
where
grpc_plugin
是grpc_csharp_plugin.exe
(或Nuget软件包的等效二进制文件)的路径。请注意,Nuget软件包实际上只是一个zip文件,因此您可以在愿意的情况下脚本下载并解压缩。作为在shell脚本中执行此操作的一个示例,您可以查看 gax -dotnet中的generateProtos.sh脚本 - 还提供了一个指定您想要
.g.cs
后缀的示例。Yes - you just need the gRPC plugin, which you can download in the
Grpc.Tools
package.You then use:
where
GRPC_PLUGIN
is the path togrpc_csharp_plugin.exe
(or the equivalent binary for your OS) from the NuGet package. Note that the NuGet package is just a zip file really, so you can script downloading it and unzipping it should you wish.As an example of doing this in a shell script, you could look at the generateprotos.sh script in gax-dotnet - that also gives an example of specifying that you want a
.g.cs
suffix.