plutoo / protobuf-csharp-port

Automatically exported from code.google.com/p/protobuf-csharp-port
Other
0 stars 0 forks source link

VS integration: custom tool to translate .proto into .cs automatically #76

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if VS could generate csharp code from proto files 
automatically. A Custom Tool is the right tool for the job.

protobuf-net has a Custom Tool: 
https://code.google.com/p/protobuf-net/source/browse/#svn%2Ftrunk%2FProtoBufGene
rator

Original issue reported on code.google.com by igorga...@gmail.com on 21 Feb 2014 at 11:33

GoogleCodeExporter commented 9 years ago
Issue 77 has been merged into this issue.

Original comment by jonathan.skeet on 21 Feb 2014 at 11:40

GoogleCodeExporter commented 9 years ago
This can be done with an external tool.

Right-click the solution and Manage NuGet Packages.  Search for 
"CSharpTest.Net.Tools" and install.  With an elevated command-prompt, browse to 
the package folder .\bin and run "CmdTool.exe install".

Then in Visual Studio, browse to the folder containing the protos.  Create a 
new xml file called "CmdTool.config" and place the following xml in this newly 
created file:

<?xml version="1.0" encoding="utf-8" ?>
<CmdTool xsi:noNamespaceSchemaLocation="CmdTool.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <match filespec="*.proto">
    <generator debug="true">
      <execute exe="ProtoGen.exe" />
      <!-- protoc.exe arguments -->
      <arg value="--proto_path=$(InputDir)\"/>
      <arg value="--include_imports"/>
      <arg value="$(InputPath)"/>
      <!-- protogen.exe arguments -->
      <arg value="-file_extension=.Designer.cs"/>
      <arg value="-namespace=$(Namespace)"/>
      <arg value="-umbrella_namespace=Generated"/>
      <arg value="-output_directory=$(InputDir)\"/>
      <arg value="-ignore_google_protobuf=true"/>
      <arg value="-public_classes=false"/>
      <arg value="-cls_compliance=false"/>
      <arg value="-nest_classes=false"/>
      <output extension=".Designer.cs"/>
    </generator>
  </match>
</CmdTool>

Change the line to include the relative path to ProtoGen.exe from the Google 
package:
      <execute exe="ProtoGen.exe" />

more information at: http://help.csharptest.net/?CmdToolConfiguration.html

Original comment by Grig...@gmail.com on 15 Sep 2014 at 8:27

GoogleCodeExporter commented 9 years ago
Given this approach, is any change suggested for the project itself? Just 
documewntation?

Original comment by jonathan.skeet on 15 Feb 2015 at 5:16