Roslyn Incremental Generator, Unity Throws Exception for source file generated in RegisterPostInitializationOutput

Hi everyone,

I’ve created a source generator and placed the output DLL in the Assets folder. The generator works as expected, and the source is generated properly. However, I’m encountering an issue where, on every domain reload/DLL re-import, errors are output to the console log.

The error message is:

Path could not be found for script compilation file '<filePath>'.

This error is thrown for each file added to the source by IncrementalGeneratorInitializationContext.RegisterPostInitializationOutput(...). While the functionality does not seam to be affected, I’d prefer to have a clear console if there are no actual issues.

Has anyone else experienced this problem or have any suggestions on how to resolve it?

Thanks in advance for your help!