I'm working on a project utilizing C# 9's Source Generator, but when the code is generated, I'm wanting different files of generated code to be emitted to specific file paths/locations within the existing project where the code is being generated.
Is this possible? I know I can specify the folder they are all placed into using:
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
and changing 'Generated' to be the folder I want the generated files to be inside of. So like if I already have a folder called 'Models,' I understand that I would change 'Generated' to 'Models' and then it would be put there.
However, once it's inside of that file path, it's put inside of a folder with the name of the source generator's project name, and then another folder with the namespace.generatorclassname.
So in this instance, what I have happening is:
- 'Generated' is the specified folder path in the project where the files are being generated
- 'SourceGenerator' is the name of project that houses the actual generator
- 'Generator' is the name of the class that actually is the legitimate Generator
- The 'CustomerTest' files are the actual files being generated
Here's a screenshot of the above scenario that I have currently happening: Screenshot of Generated Folder Structure
However, what if I want each of these files to be generated to a different location within the pre-existing folder structure of the destination project? Is that possible? Any ideas?