1

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.

melom
  • 107
  • 1
  • 13

1 Answers1

1

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.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • can you please give more information about the generators ? thank you – melom Dec 02 '20 at 15:30
  • @melom "generators" is a brand new feature in the compiler - only available for a few weeks now; I will be making use of it under protobuf-net.BuildTools (only released yesterday - it provides "analyzers" to spot problems in your usage as you type the code, in the IDE or at the command-line). However, the "generators" part is not yet complete. – Marc Gravell Dec 03 '20 at 04:40
  • @melom here's a now-working example: https://github.com/protobuf-net/protobuf-net.ToolsDemo - you're looking for `UsageDemo/Generators/ShowUsage.cs` and `UsageDemo/Generators/model.proto` – Marc Gravell Dec 03 '20 at 14:44