Windows systems, use Protobuf, compile C # file

First posted about the various versions of history Protobuf download link  https://github.com/protocolbuffers/protobuf/releases  self-created ...

Then I downloaded the 3.5.0 version here ... to pay attention to download the system ... win32 ..

I have here is unpacked into the D drive, you can put yourself another directory .. 

Unpacked directory as follows:

Go to the bin folder, and then there is a protoc.exe, this is what we need to Protobuf .. There are two ways

The first: that is my own stupid way to use ..

Enter  the C drive -> Windows -> System32 then copy the  protoc.exe copied into .. Here I encountered a small episode, after copying in, click to open the exe file, at the command line input protoc when nothing happens ... this time after I restart, again enter, all normal ..

After the restart input protoc show success:

Second implementation: is your protoc.exe  path placed under Path Windows environment variables (note that the path is in English, Chinese will not recognize)

This time it began to be a test .. I just created a folder named test, and then create a text file, change the name to test.proto ( note name suffix proto) ..

Follows

syntax = "proto3";
message DemoTest
{  
    string demoSrting = 1;  
    int32 demoInt = 2;  
    bool demoBool = 3;  
}  

The time to start compiling: 

Command line, type: 

protoc -I = --csharp_out = Source Address Destination Address Source Address /xxx.proto

Note that -I (uppercase i) is not a -L  

Written above may not quite understand, I will release my own directory command to make a detailed explanation ..

the -I = Protoc D: \ Protobuf \ the Test (here is your source directory) --csharp_out = D: \ Protobuf \ the Test (destination address) D: \ Protobuf \ the Test \ test.proto (source address)

Refer to the following:

protoc -I=D:\Protobuf\test --csharp_out=D:\Protobuf\test D:\Protobuf\test\test.proto

Tips: Copy the command line: Ctrl + insert Paste: Shift + insert

Then compiled file is required

 

 

Guess you like

Origin www.cnblogs.com/bw1219/p/10973200.html