Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating c# file from .proto file using protogen on pre build event

We've been using protobuf for a while at work and I decided to write a little console app for a client which would allow them to do some testing on site.

I started a new c# console app and downloaded google.protocolbuffers and protobuf-net from nuget.

What I'm trying to achieve is to turn my "messages.proto" file into "messages.cs"

I've tried to get the protobuf to build the messages file on a prebuild event but with no success, it seems the command arguments have changed since our first implementation. I followed the example here

http://code.google.com/p/protobuf-csharp-port/wiki/ProtoGen

And added the following pre build event

"$(projectdir)packages\Google.ProtocolBuffers.2.4.1.473\tools\protogen.exe" --proto_path=./protos protos/messages.proto --include_imports -output_directory=./

However I get the following error

Input file protos/messages.proto doesn't exist.

I've tried all sorts of combinations but nothing seems to work. Am I approaching this all wrong or is there a gotcha here? Any help much appreciated!

like image 659
Neil Avatar asked Nov 13 '22 05:11

Neil


1 Answers

Have you tried using the absolute paths? I vaguely recall having a similar issue myself that turned out to be an issue with it not resolving relative paths correctly.

like image 79
AlexC Avatar answered May 12 '23 13:05

AlexC