使用protobuf时报错 protobuf.Any 未定义

背景信息

使用命令行编译xxxx.proto时报错。

 

报错信息


google/protobuf/any.proto: File not found.
xxxxxx.proto:4:1: Import "google/protobuf/any.proto" was not found or had errors.
xxxxxx.proto:12:5: "google.protobuf.Any" is not defined.

解决方式

添加  --proto_path=..\..\packages\Google.Protobuf.Tools.3.19.3\tools  指定any.proto的路径

..\..\packages\Google.Protobuf.Tools.3.19.3\tools\windows_x64\protoc.exe -I=.\ --csharp_out=.\output\ --proto_path=..\..\packages\Google.Protobuf.Tools.3.19.3\tools .\xxxxxxx.proto

 

背景信息

使用NuGet引用的如下两个组件

Google.Protobuf.3.19.3

Google.Protobuf.Tools.3.19.3

编译工具在Tools里面,依赖库在packages\Google.Protobuf.Tools.3.19.3\tools\google\protobuf 中。

但是指定proto_path路径时,需要指定packages\Google.Protobuf.Tools.3.19.3\tools\

posted @ 2022-01-24 19:57  No5Meters  阅读(2533)  评论(0编辑  收藏  举报