melom
melom

Reputation: 107

protogen: create cs file

I am trying to use Protogen to create the C# classes this is my syntax

 <Exec WorkingDirectory="..\..\ProtoFiles" Command="$(3rdParty)\protobuf\protobuf-net\protogen.exe  --proto_path:ClientsList.proto --csharp_out:ClientsList.cs" />

but there is no C# classes created

When I used the same proto to create the C++ classes everything worked perfectly (I needed to add syntax="proto2"; I don't know if this may affect the C# part)

if I run it Manually: C:\3rdParty\protobuf\protobuf-net>protogen.exe --proto_path:ClientsList.proto --csharp_out:ClientsList.cs

Usage: protogen [OPTION] PROTO_FILES Parse PROTO_FILES and generate output based on the options given:

-IPATH, --proto_path=PATH Specify the directory in which to search for imports. May be specified multiple times; directories will be searched in order. If not given, the current working directory is used.

--version Show version info and exit.

......

Note that PROTO_FILES can be .proto or **/.proto (recursive) when a single import location is used, to process all schema files found. In recursive mode, imports from the current directory can also be specified by name-only.

Upvotes: 1

Views: 1609

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062780

The csharp_out parameter is a folder, not a file, and that isn't how you use proto_path (again, a folder); and it is =, not : - in your case you probably want:

protogen --csharp_out=. ClientsList.proto

Note the syntax is intentionally a mirror of the protoc command-line syntax.

However! There is also MSBuild package that might make it easier to work with instead of your own custom task, and I'm working on a "generators" implementation - which means zero setup: just add the .proto and run.

Upvotes: 1

Related Questions