导入Google/protobuf/timestamp.proto在Windows中找不到或有错误

发布于 2025-01-28 19:58:49 字数 789 浏览 1 评论 0原文

我正在尝试使用.proto文件生成C#代码,但是获得错误

导入Google/protobuf/timestamp.proto 没有找到或有错误。视窗

syntax = "proto3";
option csharp_namespace = "icigcppubsub1";
import "google/protobuf/timestamp.proto";

message SomeMessage {

    message Itemkey {
        string itemType = 1;
        string itemNo = 2;
    }

    message Locale {
        string countryCode = 1;
        string languageCode = 2;
    }

    message Names {
        Locale locale = 1;
        string itemName = 2;
        string presentationGroupCode = 3;
        string measurementSystem = 4;
        google.protobuf.Timestamp sourceInsertDateTime = 5;
        google.protobuf.Timestamp sourceUpdateDateTime = 6;
    }

    Itemkey itemKey = 1;
    repeated Names names = 2;
}

I am trying to generate C# code using .proto file, but getting error

import google/protobuf/timestamp.proto was not found or had errors. windows

syntax = "proto3";
option csharp_namespace = "icigcppubsub1";
import "google/protobuf/timestamp.proto";

message SomeMessage {

    message Itemkey {
        string itemType = 1;
        string itemNo = 2;
    }

    message Locale {
        string countryCode = 1;
        string languageCode = 2;
    }

    message Names {
        Locale locale = 1;
        string itemName = 2;
        string presentationGroupCode = 3;
        string measurementSystem = 4;
        google.protobuf.Timestamp sourceInsertDateTime = 5;
        google.protobuf.Timestamp sourceUpdateDateTime = 6;
    }

    Itemkey itemKey = 1;
    repeated Names names = 2;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟酉 2025-02-04 19:58:49

原因

产生了误差,因为原始可执行文件期望其库在特定位置(在同一文件夹或.. \ include)中。

解决方案

按照以下步骤。

步骤1。在包装下安装。

步骤2

。 ://i.sstatic.net/eco78.png“ alt =”显示Google..protobuf.tools executable2“>

步骤3。 >文件夹路径下方的文件
C:\Users\manishkumar\.nuget\packages\google.protobuf.tools\3.20.1\tools\windows_x64

and Paste to

C:\Users\manishkumar.ma\.nuget\软件包\ google.protobuf.tools \ 3.20.1 \工具

步骤4。更改命令提示中的执行路径。

步骤5

protoc -I="C:\Users\manishkumar\source\repos\protobuf_consoleApp" --csharp_out="C:\Users\manishkumar\source\repos\protobuf_consoleApp" "C:\Users\manishkumar\source\repos\protobuf_consoleApp\proto\*.proto"

。 > “在此处输入图像说明”

Reason

The error is produced because the protoc executable expects its libraries in particular locations (in the same folder, or in the ..\include).

Solution

Follow the following steps.

STEP 1. Install below package.

Image showing Google.Protobuf and Google.Protobuf.Tools nuget packages

STEP 2. Copy the Path of Google.Protobuf.Tools

[Shows the Path to the Google.Protobuf.Tools executable2

STEP 3. Copy the protoc.exe file from below folder path
C:\Users\manishkumar\.nuget\packages\google.protobuf.tools\3.20.1\tools\windows_x64

and Paste to

C:\Users\manishkumar.ma\.nuget\packages\google.protobuf.tools\3.20.1\tools

STEP 4. Change Execution path in command prompt.

enter image description here

STEP 5. Execute below command using .proto file

protoc -I="C:\Users\manishkumar\source\repos\protobuf_consoleApp" --csharp_out="C:\Users\manishkumar\source\repos\protobuf_consoleApp" "C:\Users\manishkumar\source\repos\protobuf_consoleApp\proto\*.proto"

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文