question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to share common proto between different projects

See original GitHub issue

Team,

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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
smartaquarius10commented, Nov 11, 2020

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.

  1. Keeping all the protos in model class library project and from there consume in every other project
  2. Keeping the protos in a folder and include them as given in Liber project.

Thank you for the help!!

1reaction
BrennanConroycommented, Nov 6, 2020

Dupe of https://github.com/grpc/grpc-dotnet/issues/183 There are some comments with MSBuild that might help you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shared gRPC protobuf files in multiple projects
The problem is that both projects runs protoc compiler and generates implementation of shared protobufs in project's obj folder.
Read more >
A question about sharing your proto files with clients : r/grpc
Hey all,. I'm new to gRPC and I'd like to learn more about how it works, so excuse the potentially naive question.
Read more >
Troubleshoot gRPC on .NET
Mismatch between client and service SSL/TLS configuration; Call a gRPC service with an untrusted/invalid certificate; Call insecure gRPC ...
Read more >
Proto Best Practices
This topic contains vetted best practices for authoring Protocol Buffers. ... Embedding the following common, shared types is strongly encouraged.
Read more >
Protocol Buffers/gRPC Codegen Integration Into .NET Build
ProtoRoot specifies a common directory that is an ancestor for a set of .proto files. It has two purposes: working out relative directories...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found