I', scratching my head about how to import "google/protobuf/empty.proto" to my proto file. What I'm doing so far:
In my .csproj file, I added the following:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Protobuf Include="C:\Users\me\.nuget\packages\google.protobuf.tools\3.10.0\tools\google\protobuf\*.proto" GrpcServices="Server"/>
<Protobuf Include="Protos\*.proto" GrpcServices="Server" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.23.2" />
<PackageReference Include="System.Reactive" Version="4.1.6" />
</ItemGroup>
</Project>
In my project folder, I have a folder called "Protos" where I have a test.proto file in which I would like to use the "empty.proto" like:
import "google/protobuf/empty.proto";
However, I get the error File not found in project
. I also do not like to specify the "3.10.0" in the ItemGroup
. What is the correct way to use google protobuf well-known types?
Protobuf is the most commonly used IDL (Interface Definition Language) for gRPC. It's where you basically store your data and function contracts in the form of a proto file.
It's possible to import proto3 message types and use them in your proto2 messages, and vice versa. However, proto2 enums cannot be used in proto3 syntax.
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.
To use the Any type, you must import the google/protobuf/any. proto definition. In the C# code, the Any class provides methods for setting the field, extracting the message, and checking the type. Protobuf's internal reflection code uses the Descriptor static field on each generated type to resolve Any field types.
if you are using resharper just follow the pic
go to r# option
uncheck the selected protobuf
reason of this issue : Though Protobuf is purely path-based and will work once the file in found on your hard disk ReSharper needs all the files added to solution in order to process them and Current implementation of included files' search inside protobuf support does not allow to find the files outside the solution.
have good time
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With