I've created a source generator that reads in some information from a config file, allowing the consumer to change settings that alter the output of the generator. That file is added to the consuming project by adding the following to the .csproj file:
<ItemGroup>
<AdditionalFiles Include="generator.config" />
</ItemGroup>
I'd like for coworkers to be able to install my nuget package and have the generator.config file as well as the above ItemGroup automatically added to their projects.
I thought this would be rather simple, but I've spent days trying to achieve this with no luck so far and I'm ready to pull my hair out. I've tried:
- Including generator.config in the content and contentFiles directories of the package. This did get the file into the consuming project, but it wasn't editable, which made it useless a config file.
- Various permutations of .props and .targets files in my nuget package. I managed to get generator.config copied to the output directory after building, but not to the project directory
- I found some posts talking about about running a powershell script to copy files on install but that seemed like that's a deprecated way to go about this
I think I may be experiencing some additional difficulty due to my consuming project targeting .NET 6, while the source generator has to target netstandard2.0. I only have a passing familiarity with Nuget/MSBuild from looking at .csproj files so I suspect I may be missing something fairly obvious, but any help/suggestions would be appreciated.