VS build under .Net 4.8

13 views
Skip to first unread message

Tom Hintz

unread,
Jan 7, 2021, 2:56:51 PM1/7/21
to Protocol Buffers
I'm experimenting with retro-fitting a .Net 4.8 service with a gRPC service and I'm unclear how this works.  I followed a tutorial that specified adding the following to the project.  I assume the .csproj file:


  <ItemGroup>
    <Protobuf Include="**/*.proto" />
  </ItemGroup>

This doesn't appear to create output.  I then added a custom pre-build step the produces one file ProtoModels\Licenses.cs.

%USERPROFILE%\.nuget\packages\google.protobuf.tools\3.14.0\tools\windows_x86\protoc.exe --proto_path=$(ProjectDir)Protos --csharp_out=$(ProjectDir)ProtoModels   Licenses.proto

In constrast, the Greet sample generates a Greet.cs and GreetgRPC.cs in obj\Debug\netcoreapp3.1.

Can someone clarify the best way to retrofit an older .Net 4.8 visual studio csproj to build a gRpc service?

Tom Hintz

unread,
Jan 11, 2021, 4:44:17 PM1/11/21
to Protocol Buffers
This configuration is not supported?

Tom Hintz

unread,
Jan 12, 2021, 4:57:09 PM1/12/21
to Protocol Buffers
We did solve this, primarily by switching tools.  Previously NuGet's Google.Protobuf.Tools was used in conjunction with a Visual Studio 2019 pre-build event that manually called protoc.  Both Google/Timestamp.proto and Google/Empty.proto were added to the Protos folder.  For some reason these were added to the proto compile step by visual studio which had the bad effect of creating duplicate definitions.  In addition, the gRpc service was never generated.  We dropped Google.Protobuf.Tools and instead referenced the NuGet gRpc.Tools package and removed the extra proto builds from the csproj.  It works.
Reply all
Reply to author
Forward
0 new messages