I\'m trying to use protobuf in a C# project, using protobuf-net, and am wondering what is the best way to organise this into a Visual Studio project structure.
When manu
Calling a pre-build step but using project variables (e.g. $(ProjectPath)
) to create absolute filenames without having them actually in your solution would seem a reasonable bet to me.
One thing you might want to consider, based on my past experience of code generators: you might want to write a wrapper for protogen which generates code to a different location, then checks whether the newly generated code is the same as the old code, and doesn't overwrite it if so. That way Visual Studio will realise nothing's changed and not force that project to be rebuilt - this has cut build times dramatically for me in the past.
Alternatively, you could keep an md5 hash of the .proto file the last time protogen was executed, and only execute protogen if the .proto file has changed - even less to do on each build!
Thanks for raising this as a question though - it clearly suggests I should work out a way to make this an easy pre-build step for my own port.