xref: /aosp_15_r20/external/grpc-grpc/src/csharp/Grpc.Tools/README.md (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1*cc02d7e2SAndroid Build Coastguard Worker# Grpc.Tools - Protocol Buffers/gRPC C# Code Generation Build Integration
2*cc02d7e2SAndroid Build Coastguard Worker
3*cc02d7e2SAndroid Build Coastguard WorkerThis package provides C# tooling support for generating C# code from `.proto` files in `.csproj` projects:
4*cc02d7e2SAndroid Build Coastguard Worker* It contains protocol buffers compiler and gRPC plugin to generate C# code.
5*cc02d7e2SAndroid Build Coastguard Worker* It can be used in building both grpc-dotnet projects and legacy c-core C# projects.
6*cc02d7e2SAndroid Build Coastguard Worker
7*cc02d7e2SAndroid Build Coastguard WorkerThe package is used to automatically generate the C# code for protocol buffer messages
8*cc02d7e2SAndroid Build Coastguard Workerand gRPC service stubs from `.proto` files. These files:
9*cc02d7e2SAndroid Build Coastguard Worker* are generated on an as-needed basis each time the project is built.
10*cc02d7e2SAndroid Build Coastguard Worker* aren't added to the project or checked into source control.
11*cc02d7e2SAndroid Build Coastguard Worker* are a build artifact usually contained in the `obj` directory.
12*cc02d7e2SAndroid Build Coastguard Worker
13*cc02d7e2SAndroid Build Coastguard WorkerThis package is optional. You may instead choose to generate the C# source files from
14*cc02d7e2SAndroid Build Coastguard Worker`.proto` files by running the `protoc` compiler manually or from a script.
15*cc02d7e2SAndroid Build Coastguard Worker
16*cc02d7e2SAndroid Build Coastguard Worker## Simple example
17*cc02d7e2SAndroid Build Coastguard Worker
18*cc02d7e2SAndroid Build Coastguard WorkerTo add a `.proto` file to a project edit the project’s `.csproj` file and add an item group with a `<Protobuf>` element that refers to the `.proto` file, e.g.
19*cc02d7e2SAndroid Build Coastguard Worker
20*cc02d7e2SAndroid Build Coastguard Worker```xml
21*cc02d7e2SAndroid Build Coastguard Worker<ItemGroup>
22*cc02d7e2SAndroid Build Coastguard Worker    <Protobuf Include="Protos\greet.proto" />
23*cc02d7e2SAndroid Build Coastguard Worker</ItemGroup>
24*cc02d7e2SAndroid Build Coastguard Worker```
25*cc02d7e2SAndroid Build Coastguard Worker
26*cc02d7e2SAndroid Build Coastguard WorkerFor more complex examples and detailed information on how to use this package see: [BUILD-INTEGRATION.md](https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md)
27