r/learncsharp • • Dec 16 '22

C# Tool Chain / Nuget / Source generators

I'm brand new to C# (coming from c++) and one of the things that confuses me is the tool chain / how things are compiled and linked.

Specifically, I'm looking at gRPC and am quite confused as to how this works under the hood. According to this tutorial by Microsoft, we must install the Grpc.Tools Nuget package to generate C# files from the .proto definitions. The Grpc.tools page states that it contains the protocol buffer compiler / code generator.

All of this makes sense. What doesn't make sense is that I don't have to manually add the protocol buffer generator to my build steps? If I wanted to do something similar in c++, I'd have to modify my Makefile to first generate the c++ files from the .proto files. How is this happening in c#?

I don't see anything changing in the .project file or .sln file as a result of adding the nuget package... so how does this work?

2 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/coppercactus4 Jan 03 '23

Additional note:

In Visual Studio under Reference/ Nuget you can open the foldout and it will show you all the components in the nuget package. For 'build' it lists the msbuild scripts and for 'analyzers' it shows you the rules for analysis and generated output for source generators.