背景信息
使用命令行編譯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\