AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 60 forks source link

How to generate code during a build pipeline #157

Closed mwpowellhtx closed 4 years ago

mwpowellhtx commented 4 years ago

I've got an internal code generator that I need to have engaged during the build pipeline. The project itself also carries with it several dependencies in its own right. Do I need to have the feeder generator project report its output to the consuming project for CG to take place? I take it that any references, project or package dependencies that it requires must also land there in order for CGR to properly activate an instance of the generator(s) themselves?

Illustrating, something like this:

project/package references -> code generator project(s) -> consumer project (i.e. where CG will actually happen)

All of which, project/package references, code generator project(s), and so on, must land in the consumer project (or somewhere) where we identify the code generator assets to CGR.

Thanks...

amis92 commented 4 years ago

If you're asking about this repository, the dotnet-codegen tool requires that folder containing generator's DLL (and all it's required dependencies) is included in GeneratorAssemblySearchPaths or ReferencePath.

https://github.com/AArnott/CodeGeneration.Roslyn/blob/246ca6a3a01b24f2793293f03ed80e99a7ba0ed1/src/CodeGeneration.Roslyn.BuildTime/build/CodeGeneration.Roslyn.BuildTime.targets#L32-L44