AArnott / CodeGeneration.Roslyn

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

Working sample of a generator as NuGet package #173

Closed klenium closed 4 years ago

klenium commented 4 years ago

Is there a sample project available that contains a generator project built with CodeGeneration.Roslyn, and which is deployed with NuGet? Maybe if I could look at a working sample project, I could figure out why mine is not working.

I have troubles setting up NuGet package for my (locally working) generator. I read that right now there is an issue with directories, but I simply put both my generator and attribute's .dll-s into all dirs. The generator now runs, however, it is unable to load Microsoft.CodeAnalysis.Workspaces, I have no idea why. I also tried to put this dll to the package, or adding as a dependency, but no luck.

amis92 commented 4 years ago

I don't think there is.

You can take a look my RecordGenerator - it is packaged as NuGet. https://github.com/amis92/RecordGenerator

Also, dependencies in general are not really supported. You can try your luck with MS.CA packages of the exact same version as the one used by CG.R (https://github.com/AArnott/CodeGeneration.Roslyn/blob/master/src/Directory.Build.props#L22 )

klenium commented 4 years ago

Ah, thanks, I didn't know dependencies are not supported. I removed them, and now it works. This way doesn't support using typeof and nameof in some cases, or Microsoft.CodeAnalysis.Formatting, but that's acceptable for now.