Enable referencing proto files in NuGet packages
See original GitHub issueA common pattern in other languages is that your proto files are not part of your project, especially if you are a client but ofter also when you are a server.
Certainly in enterprises that have their stack build on gRPC. What you see is that the proto’s are managed in a common mono repo for all contracts (were talking mono-repo for the proto files only here). What you then often see is that contract repo has a language specific distribution step. This do not create client libraries, they just publish the proto files in a package format idiomatic to the language (an example is Java: they package the proto files in a jar package and publish them to a maven repo, in general a private one of the company).
What I like to see is that the .NET implementation would be able to reference proto in NuGet that it can fetch from a NuGet repository. That will make it easier for enterprises to adapt gRPC in .NET. They only need to add the NuGet distribution step in one place and a project just need to references NuGet as an external dependency.
Let me also stress that this is distributing the proto files and not client libraries. You want to avoid distribution of clients that are build with an older version of proto as the one you are using in your project.
And example how this works in Java (using gradle):
dependencies {
compile("com.google.protobuf:protobuf-java:3.6.1")
compile("io.grpc:grpc-protobuf:1.18.0")
protobuf('io.anemos:protobeam-options-proto:0.0.3-SNAPSHOT')
}
The 3th dependency points to an artifact just containing proto, gradle will make sure that client/server stubs are generate with the same version of gRPC and protobuf as the project is.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:30
- Comments:42 (3 by maintainers)
Top GitHub Comments
If you want to ship .proto files in a nuget package for reuse in .proto files in your own project you can do this:
The key here are the
GeneratePathProperty
andAdditonalImportDirs
attributes.In the MyCompany.ProtoBuf package you need to have something like this:
to get the proto files inlcuded.
Hey @JamesNK @jtattermusch , what needs to happen here? It seems like there is demand for this, what needs to happen for the pr to be accepted?