Search code examples
protocol-buffersrider

Should I expect Rider to compile Protobuf?


I'm evaluating Rider 2022.3.1. I created a new solution with a library project and added this .proto definition:

syntax = "proto3";
package Generated;

message Fnord {
  string Foo = 1;
  int32 Bar = 2;
}

Then I manually added it to the project file:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="Google.Protobuf" Version="3.21.12" />
    </ItemGroup>
    
    <ItemGroup>
        <Protobuf Include="Test.proto" />
    </ItemGroup>

</Project>

Building this project doesn't emit any errors, but it also doesn't appear to compile my .proto file. The namespace Generated isn't visible to other classes.

What am I missing?


Solution

  • The package Grpc.Tools contains the code generators for both Protobuf and gRPC. You must reference this package in your project even if you're not using gRPC.

    https://chromium.googlesource.com/external/github.com/grpc/grpc/+/HEAD/src/csharp/BUILD-INTEGRATION.md