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!

4 Likes

I have the same issue after updating to the latest version of Unity (6…) using TypedSignalR.Client.

The errors can be ignored in my case as well.

Having the same issue over here after updating to Unity 6000.0.26f1. Worked fine in 2022.3.20f1.

Bump.

Any update on this? Im having the same issues - Source Generator work fine on older versions…still works, but has this super annoying error all the time.

+1 experiencing something similar. I’m using a non-incremental ISourceGenerator and I get a similar error but everything seems to be working fine.

Version 6000.0.34f1 has finally resolved this frustrating issue. Hallelujah!