If you create a Roslyn Source Code Generator that uses inside a base class or a static class, the best way, in my opinion , is to create 2 separate nuget packages : one for the code generated and one for the base class. This way the project that will use your RSCG will use just the nuget package that have the base class and get rid of the generator . More, you can add a third project to register some extensions to Web project .
Let’s see in practice with RSCG_AMS :
I have a NuGet package with the base class AboutMySoftware – https://www.nuget.org/packages/AMS_Base/
The RSCG generates derived classes of AboutMySoftware – has a dependency in the AMS_Base – the name is RSCG_AMS : https://www.nuget.org/packages/RSCG_AMS/ . This will generate code during the build and will not be included in the output.
Finally, I have an extension for WebAPI – AMSWebAPI – that registers the endpoint in the Web Project to display /ams url .
I think that this is a normal organization of RSCG projects.
Also, add documentation for each class / public item generated. There can be projects that will require this ( as a compiler/ property flag )