我正在尝试使用 .bat 文件生成 grpc .cs 文件,但没有生成 messageGRPC.cs 文件。但是,message.g.cs 确实被创建了。没有错误,我什至尝试对路径进行硬编码并以管理员模式运行命令窗口,结果相同。
再次,message.g.cs 确实生成正确,但 messageGRPC.cs 没有。
在我的项目中,我从 NuGet 安装了 Google.Protobuf、Google.Protobuf.Tools、Grpc、Grpc.Core 和 Grpc.Tools。
有什么我做错了吗?
@echo off
cd %~dp0
:: Display Current Working Directory used for debugging
:: echo Current Directory = %CD%
set PROJ_ROOT=%CD%
set ROOT_DIR=%CD%
:: Display Solution Root Directory used for debugging
:: echo Root Directory = %ROOT_DIR%
:: Set path variables
set SRC_DIR=%ROOT_DIR%\Common\Messages
set PLUGIN_DIR=%ROOT_DIR%\<project>\packages\Grpc.Tools.1.3.0\tools\windows_x64
set DST_DIR=%ROOT_DIR%\Common\Messages\proto3
:: debugging
echo plug_in_dir = "%PLUGIN_DIR%"
echo Started compiling .proto messages using protoc version
"%PLUGIN_DIR%"\protoc.exe --version
:: code is on one line. it's wrapped here for readability
"%PLUGIN_DIR%"\protoc.exe -I "%SRC_DIR%" --proto_path="%SRC_DIR%"
--csharp_opt=file_extension=.g.cs --csharp_out="%DST_DIR%" "%SRC_DIR%"\message.proto
--grpc_out="%PROJ_ROOT%"\gRPC
--plugin=protoc-gen-grpc="%PLUGIN_DIR%"\grpc_csharp_plugin.exe
cd %PROJ_ROOT%
echo Completed compiling .proto messages