grpc-dotnet
grpc-dotnet copied to clipboard
Consider removing C# only check for Grpc.Tools
What version of gRPC and what language are you using?
Language: F# gRPC Version: 2.45.0
What operating system (Linux, Windows,...) and version?
Fedora 35
What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info
)
6.0.202
What did you do?
Added Grpc.AspNetCore as an dependency to an F# project
What did you expect to see?
The project should restore properly
What did you see instead?
/workspace/nuget_cache/grpc.tools/2.46.1/build/_protobuf/Google.Protobuf.Tools.targets(51,5): error : Google.Protobuf.Tools proto compilation is only supported by default in a C# project (extension .csproj) [/workspace/monorepo/src/protobuf/bootstrap/service/protobuf.bootstrap.service.fsproj]
Grpc.Tools only supports C#.
Grpc.AspNetCore is a metapackage that references Grpc.AspNetCore.Server. Just reference Grpc.AspNetCore.Server directly.
Ah! Thanks for taking your time solving this for me!
I would like to suggest adding this bit of information to the .NET gRPC docs since this is not very obvious for those who are not using C#.
I think we can close this one after
- documenting the workaround here in this issue thread (is think the default warning can be overridden)
- I don't think we need to document this explicitly in Grpc.Tools documentation, AFAIK overwhelming majority of Grpc.Tools usage is with C# and its documentation here only ever mentions C# which IMHO makes it reasonably clear that other languages might not be supported by default (also see here )
@tonydnewell can you please look into what need to done as a workaround? (I think setting a property in a project is enough but I don't recall the name of the property).
As said here https://github.com/grpc/grpc-dotnet/issues/1742#issuecomment-1126131576 the solution is to use the NuGet package Grpc.AspNetCore.Server
instead of Grpc.AspNetCore
.
Another workaround is to set the property <Protobuf_ProjectSupported>true</Protobuf_ProjectSupported>
in the project file - that will only have the effect of supressing the error message, but no code will be generated from the protocol buffers files.
We could detect F# projects in Grpc.Tools
and print a warning instead of an error, but I'm not sure that is any better.