I am trying to build out a large system using gRPC. I have a project where I define a .proto file. I create a second project that takes a reference to the first project. I want to be able to use a message defined in the first project's proto file in a message defined in the second project's proto file. Is this possible?
Asked
Active
Viewed 1,268 times
2 Answers
0
In these cases I always place the proto files in their own repository. For example if you are using git you then use the repository with definition files in both of your projects as a submodule.
In the end you will have three repositories:
- Message definitions
- Project A
- Project B
Project A and B will refer to the Message definitions repository.

Bart
- 1,405
- 6
- 32
-
Thanks for the answer. This was/is my plan B. I was hoping that there was a way I could encapsulate project specific proto files in that specific project. and access them from the other projects. I will likely end up doing something like this in the end. – Dave May 31 '19 at 14:13
0
I answered a similar question here: https://stackoverflow.com/a/59821705/9742876
In short, it's possible to do this if you add ProtoRoot
attribute to your <Protobuf />
section in the .csproj
file. ProtoRoot
changes the root folder where the import
statement starts searching for .proto
files, but check out the link above for more info.

Ivan Ivković
- 417
- 3
- 14