© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
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()
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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Source Generator AdditionalFiles Batching missing metadata
C#CC# / help
2y ago
source generator
C#CC# / help
3y ago
❔ Native DLL in source generator
C#CC# / help
4y ago
❔ Source generator & protobuf
C#CC# / help
4y ago