Build asp net core with grpc, errors: wellknowntype not found
I build an asp net core API project with a docker. This project contains some proto files and imports some google well-known types. But I got output errors:
- google/protobuf/Timestamp.proto : error : File not found. [/src/mymy/mymy.csproj] - Protos/notification.proto(4,1): error : Import "google/protobuf/Timestamp.proto" was not found or had errors. [/src/mymy/mymy.csproj] - Protos/notification.proto(112,5): error : "google.protobuf.Timestamp" is not defined. [/src/mymy/mymy.csproj]
I put my source code in github: https://github.com/pearl2201/docker-aspnetcore-grpc
It is correct… they’re not defined; with Grpc.Tools
, imports still need to exist. You can use the ProtoRoot
option on the <Protobuf ...>
line to tell it where the root is, for this purpose. In BUILD-INTEGRATION there is also some mention of $(Protobuf_StandardImportsPath)
, but that seems to refer only to <ProtoCCommand>
.
(as an aside: the protobuf-net tools include copies of all the common imports inside the package; if they aren’t resolved from the file system, it looks to see what it has inside the assembly instead, but: this is not a direct change, as the protobuf-net tools output very different C#, intended for a different library implementation).