Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import "google/api/annotations.proto" was not found or had errors #879

Closed
rabejens opened this issue Apr 23, 2020 · 5 comments
Closed

Import "google/api/annotations.proto" was not found or had errors #879

rabejens opened this issue Apr 23, 2020 · 5 comments
Labels
question Further information is requested

Comments

@rabejens
Copy link

I followed the three steps in your blog but I am getting above error.

What else do I have to do to make the dependencies available?

@rabejens rabejens added the question Further information is requested label Apr 23, 2020
@JamesNK
Copy link
Member

JamesNK commented Apr 24, 2020

You need to have a copies of a couple of proto files in your project. I've updated the instructions: http://james.newtonking.com/archive/2020/03/31/introducing-grpc-http-api

@JamesNK JamesNK closed this as completed Apr 24, 2020
@mfc19
Copy link

mfc19 commented May 28, 2020

@JamesNK I followed the instructions and in my .Net project I still have build errors:

Error Import "google/api/annotations.proto" was not found or had errors.

I have the google files in a google\api directory in my project

@dennisroche
Copy link

dennisroche commented Sep 29, 2020

I found in VS 2019 Preview and in the gRPC HTTP API sample that I needed to include the google *.proto files into the project.

The most effective way I've found to do this is:

    <Protobuf Include="..\Proto\google\api\*.proto">
      <Link>Protos\google\api\%(Filename)%(Extension)</Link>
    </Protobuf>

@Pao-lino
Copy link

Pao-lino commented May 20, 2021

@mfc19 I've have the same issue, did you find a solution ?
EDIT: solved by this
#167 (comment)

@sailingKieler
Copy link

Hi, I just wanna add my two cents in here, it might help others in future.

I'm new to building a gRPC client within an ASP.NET backend app (using net8.0), and I got the Protobuf definitions supplied by another party, requiring google/api/annotations.proto and others beyond the Protobuf Well-known Types. Here's how I solved it:

  • There's the NuGet package Google.Api.CommonProtos that contains annotations.proto and many more, and which I imported as follows. Note the setting of GeneratePathProperty="true".
<PackageReference Include="Google.Api.CommonProtos" Version="2.15.0" GeneratePathProperty="true" />
<PackageReference Include="Google.Protobuf" Version="3.27.3" />
<PackageReference Include="Grpc.Tools" Version="2.65.0" PrivateAssets="All" />
  • After dotnet restore you will find the google/**/*.protos in <userHome>/.nuget/packages/google.api.commonprotos/2.15.0/content/protos/
  • I then registered my proto files including an additional setting of AdditionalImportDirs like this
<Protobuf ProtoRoot="Proto" Include="Proto/**/*.proto" GrpcServices="Client" AdditionalImportDirs="$(PkgGoogle_Api_CommonProtos)/content/protos"/>
  • run dotnet build

Et voilà! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants