使用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\


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM