C# gRPC未生成

C# gRPC未生成,c#,grpc,C#,Grpc,我目前正在尝试在现有的ASP.NET核心应用程序中实现gRPC服务器。但是C绑定并没有生成以在应用程序中使用。我已安装以下依赖项: Grpc 谷歌 核心 Grpc.工具 我已将.proto文件添加到项目中的Protos文件夹中。我有以下.proto配置: syntax = "proto3"; //Request that comes through from the microservice endpoint message RegistrationRequest { string t

我目前正在尝试在现有的ASP.NET核心应用程序中实现gRPC服务器。但是C绑定并没有生成以在应用程序中使用。我已安装以下依赖项:

Grpc 谷歌 核心 Grpc.工具 我已将.proto文件添加到项目中的Protos文件夹中。我有以下.proto配置:

syntax = "proto3";

//Request that comes through from the microservice endpoint
message RegistrationRequest {
    string type = 1;
    string ipAddress = 2;
}

//Response on the service register endpoint
message RegistrationResponse {
    bool accepted = 1;
}

//Request to get API endpoint to use based on type
message HostRequest {
    string type = 1;
}

//Response of the host request
message HostResponse {
    string ipAddress = 1;
}

//Service for the repository
service ServiceRepoServer {
    //Method that will register the endpoint on the repo
    rpc RegisterEndpoint (RegistrationRequest) returns (RegistrationResponse) {}
    //Method that will return an endpoint based on type
    rpc RequestEndpoint (HostRequest) returns (HostResponse) {}
} 

我试过清理和重建,但都没有用。这可能是我在某处遗漏的一些小东西,但我不确定它是什么。有人有想法吗?

您需要编辑csproj,例如,默认的greet.proto执行以下操作:

GrpcServices参数也可以是Client,也可以同时是Client和Client,具体取决于您需要什么

如果您使用的是Visual Studio 2019,还可以使用生成操作来完成此操作。右键单击proto文件并选择属性。在生成操作中选择Protobuf编译器


您需要编辑csproj,例如,默认的greet.proto执行以下操作:

GrpcServices参数也可以是Client,也可以同时是Client和Client,具体取决于您需要什么

如果您使用的是Visual Studio 2019,还可以使用生成操作来完成此操作。右键单击proto文件并选择属性。在生成操作中选择Protobuf编译器


您是否编辑了csproj文件?另外,您是否使用.Net Core 3.0?@LeisenChang-使用.Net Core 3.0,不,我没有编辑csproj文件。有什么需要添加的吗?你编辑过csproj文件吗?还有,你使用的是.Net Core 3.0吗?@LeisenChang-使用的是.Net Core 3.0,没有,我没有编辑csproj文件。有什么需要添加的吗?Grpc项目还提供了一个.NET全局工具,允许您管理protobuf引用。请参阅Grpc项目中的文档,该项目还提供了一个.NET全局工具,可用于管理protobuf引用。请参阅位于的文档