4

I followed the "hello world" grpc tutorial to create a grpc server and client project in .net core (3.0). Everything worked very well. When i walked through the steps of adding the .proto file to the client project, i wondered if there is a way to avoid copying the file and instead add the servers .proto file as link the client project.

From the docs on how to add the proto file to the client:

  • Create a Protos folder in the gRPC client project.
  • Copy the Protos\greet.proto file from the gRPC Greeter service to the gRPC client project.

the copied file is then added to the client .csproj like this:

<ItemGroup>
  <Protobuf Include="Protos\greet.proto" GrpcServices="Client" />
</ItemGroup>

Is it possible to add the .proto file from the server project as a link to the client?

1 Answer 1

5

After some trial and error i found a way to do it. You can set the include property to the path of the file you want to link and the Link property to the path you you want the file to be displayed in your project:

<ItemGroup>
    <Protobuf Include="..\GreeterService\Protos\greet.proto" Link="Protos\greet.proto" GrpcServices="Client" />
</ItemGroup>

I found a blog post explaining how to add linked files to a .net core csproj here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.