grpc / grpc/grpc-dotnet

How to use this in a CMake C# project?

Open
#2,517 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

I need to write a simple gRPC server for my Proto file in C#. Unfortunately, I have very little experience with C#. I am a C++ developer.

For internal project reasons, I would like to use CMake. What should a minimal project look like in which a gRPC server is implemented with grpc-dotnet?

It would be great if you could add a CMake project to the examples directory.

My current state is:

```cmake
cmake_minimum_required(VERSION 3.11)

set(CMAKE_GENERATOR_PLATFORM Win32)
set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk")
set(CMAKE_DOTNET_TARGET_FRAMEWORK "net8.0")
set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.8")

project(AppName LANGUAGES CSharp)

file(GLOB SOURCE_FILES "*.cs")
add_executable(App ${SOURCE_FILES})
set_target_properties(App PROPERTIES VS_DOTNET_REFERENCE_Grpc_AspNetCore "Grpc.AspNetCore")
```

This enables me to create a VS Solution the I can open with Visual Studio. There I need to install Grpc.AspNetCore via right click on the project / Manage NuGet Packages.

I didn't find out yet how to add the Proto file.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing examples directory and the CMake project shown in the issue, then determine how its Proto file and Grpc.AspNetCore dependency should be represented. Done means a minimal CMake project example in the examples directory that builds a C# gRPC server from a Proto file.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, csharp, grpc
Domain
backend-api-design, build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.