Unable to share common proto between different projects
See original GitHub issueTeam,
I’m migrating one of my MVC based .net framework api to grpc. Currently, I have one entity class in model project which is referenced in main and dbcontext project. Now, I’m trying to make same like this with grpc .net core project where, I have one main project which has service proto files and a model class library project having messages proto files.
In my main project I wanted to use this message protos, but the moment I run this command on my main project
dotnet grpc add-file "path to message proto"
It edits the .csproj of main project and add this
<ItemGroup> <Protobuf Include="..\Watcher\Protos\entities.proto" Link="Protos\entities.proto" GrpcServices="Client" /> </ItemGroup>
This adds a copy of this file entities.proto into the Protos folder of main project as well. Now, the moment I try to use it I get ambiguous conflicts and type casting errors: CS04236 & CS00029.
This is obvious because now indirectly, I have 2 proxy classes build by the proto file of same name and same namespace.
Is there anyway to use the proto file which is build in one project and only referenced in other projects like the way we do in .net framework MVC projects.
Please help!!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Thanks a lot @JamesNK and @chwarr , I’m able to use the protos from common place now. The main problem is that I was keeping few protos in project A which is the main project and other in model class library project B.
Both approaches are working now.
Thank you for the help!!
Dupe of https://github.com/grpc/grpc-dotnet/issues/183 There are some comments with MSBuild that might help you.