I ran into something like this. It happened when I used one project as a basis for another and renamed things. In my case, I accidentally omitted the dot in “Source/[ProjectName].Target.cs” between the name of my project and “Target”. Very hard to know what was wrong from the error, but afterwards it compiled like normal. I suspect its something similar - something in one of the build files.
It was tricky to see in my case, since there are two files: “Source/[ProjectName].Target.cs” and “Source/[ProjectName]Editor.Target.cs”. Since the editor one was fine, I didn’t run into this problem until packaging. In my case this was all on Windows, so not necessarily related to the platform I think.