C
C#13mo ago
Toreole

❔ Access AdditionalFiles in source generator

[solved] Ive got a netstandard2.0 source generator project that is supposed to read text via the context from a file that is included in the csproj of the generator like this:
<ItemGroup>
<AdditionalFiles Include="TextFile.txt"/>
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="TextFile.txt"/>
</ItemGroup>
The file is in the same directory as the .csproj however when i try to access the GeneratorExecutionContext's files: context.AdditionalFiles.First() it throws an exception "Sequence contains no elements" what little i can find on the topic online is inconclusive. some samples dont include any additional files, some have them in entirely different projects. what is the deal here?
2 Replies
Toreole
ToreoleOP13mo ago
Okay yeah solved. So it isnt well explained at all in the barely existing documentation for it, but AdditionalFiles have to be declared in the project that the source generator is being used in, not in the source generator itself. that isnt immediately obvious, but it does make sense tbf
Accord
Accord13mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server