C#C
C#3y 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>

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?
Was this page helpful?