IceRpc.Protobuf.Tools 0.3.1

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package IceRpc.Protobuf.Tools --version 0.3.1                
NuGet\Install-Package IceRpc.Protobuf.Tools -Version 0.3.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IceRpc.Protobuf.Tools" Version="0.3.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IceRpc.Protobuf.Tools --version 0.3.1                
#r "nuget: IceRpc.Protobuf.Tools, 0.3.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IceRpc.Protobuf.Tools as a Cake Addin
#addin nuget:?package=IceRpc.Protobuf.Tools&version=0.3.1

// Install IceRpc.Protobuf.Tools as a Cake Tool
#tool nuget:?package=IceRpc.Protobuf.Tools&version=0.3.1                

Protobuf Tools for IceRPC

IceRpc.Protobuf.Tools allows you to compile Protobuf definitions (in .proto files) into C# code (in .cs files) within MSBuild projects.

This package includes the Protobuf compiler, protoc, and the protoc-gen-icerpc-csharp generator. The protoc compiler is a native tool with binaries for Linux x64, macOS x64 and Windows x64. The protoc-gen-icerpc-csharp generator is a .NET program and requires .NET 8 or later.

Once you've added the IceRpc.Protobuf.Tools NuGet package to your project, the Protobuf files of your project are automatically compiled into C# files every time you build this project.

The protoc compiler contains several built-in generators, including the C# generator which is responsible for generating the Protobuf serialization and deserialization code for C#. In addition to these built-in generators, protoc also executes the external protoc-gen-icerpc-csharp generator which is responsible for generating the IceRPC + Protobuf integration code.

The protoc C# generator generates a .cs file for each .proto file. The generated C# file has the same name as the corresponding .proto file, but with the name converted to Pascal case. For example, greeter.proto is compiled into Greeter.cs.

The protoc-gen-icerpc-csharp generator generates a .IceRpc.cs file for each .proto file. The generated C# file has the same name as the corresponding .proto file, but with the name converted to Pascal case. For example, greeter.proto is compiled into Greeter.IceRpc.cs.

Source code | Package

Protobuf files and Protobuf search path

The Protobuf compiler accepts two main inputs:

  • the Protobuf files to compile into C# code (the Protobuf files)
  • directories that contain imported Protobuf files (the Protobuf search path)

You select which files to include in your project's Protobuf files with the ProtoFile item type. And you select which paths to include in your project's Protobuf search path with the ProtoSearchPath item type.

By default, all .proto files located in your project's home directory and any of its subdirectories, recursively, are included in ProtoFile. You can prevent this auto-inclusion of .proto files by setting either EnableDefaultItems or EnableDefaultProtoFileItems to false. The default value of these properties is true.

You can also add Protobuf files to your project explicitly. For example:

<ItemGroup>
    <ProtoFile Include="../greeter.proto"/>
</ItemGroup>

This adds greeter.proto to your project's Protobuf files even though this file is not in the project's home directory or any of its subdirectories.

The Protobuf search path is an aggregate of the ProtoSearchPath defined in your project (if any) and the ProtoSearchPath defined in NuGet packages referenced by your project.

For example, if your project's Protobuf files import files in directory common/proto, set your ProtoSearchPath as follows:

<ItemGroup>
    <ProtoSearchPath Include="$(MSBuildThisFileDirectory)../common/proto"/>
</ItemGroup>

ProtoFile item metadata

You can use the following ProtoFile item metadata to customize the compilation of your Proto files. Each unique set of options results in a separate execution of protoc.

Name Default Description
AdditionalOptions Specifies additional options to pass to [protoc] compiler.
OutputDir generated Sets the output directory for the generated code. This metadata corresponds to the --csharp_out and --icerpc-csharp_out options of protoc.
Pack false Specifies whether or not to include the items (Proto files) in the NuGet package.
PackagePath protobuf Sets the target path in the NuGet package. Used only when Pack is true.

Generated code and NuGet packages

You need to reference the IceRpc.Protobuf NuGet package to compile the generated C# code. Referencing IceRpc.Protobuf makes your project reference transitively IceRpc, Google.Protobuf and System.IO.Pipelines.

Protobuf compiler

This package includes the protoc compiler binaries, and the Protobuf well-known type definitions from the Google.Protobuf.Tools package. Additionally, it includes the protoc ARM64 binaries for Linux and macOS from the `Google Protobuf release page.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on IceRpc.Protobuf.Tools:

Repository Stars
icerpc/icerpc-csharp
A C# RPC framework built for QUIC, with bidirectional streaming, first-class async/await, and Protobuf support.
Version Downloads Last updated
0.4.0.1 185 9/17/2024
0.4.0 140 9/16/2024
0.3.1 379 3/28/2024
0.3.0 327 2/14/2024
0.2.1 275 12/12/2023
0.2.0.1 236 12/4/2023
0.2.0 124 12/4/2023