Can't reference another assembly from Roslyn Source Generator inside Unity

Hi! I tried for many hours and I need to ask for help.

I got a managed plugin (dll) with Access enum type defined.

In another c# library class project (source generator) I have a reference to the first project or to compiled dll from first project (it doesn’t matter). I see Access enum, everything works and etc.

When I copy these two dlls into Unity, I got this error:

Source generator error:
System.IO.FileNotFoundException: Could not load file or assembly 'Polyflair.Codebase.SourceGeneration.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Cannot find a file.
File name: 'Polyflair.Codebase.SourceGeneration.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

Why doesn’t it work in Unity? Why source generator doesn’t see first project (Common)?

Rest of the Unity scripts can see Access type from Common dll, but SourceGenerator (second dll) doesn’t.

Probably this is the same problem I got right now:

but the answer is not satisfactory to me. It didn’t solve the problem with dll visibility.

Access is defined in Polyflair.Codebase.SourceGeneration.Common
Then I am using this enum inside Unity project and in SG to perform some logic on it. That’s why I paste the compiled dll into Unity and reference the csproj as dependency for SG.

I tried defining reference inside SG.csproj like this (this path is probably stupid):

  <ItemGroup>
    <Reference Include="Polyflair.Codebase.SourceGeneration.Common">
      <HintPath>bin\Release\netstandard2.0\Polyflair.Codebase.SourceGeneration.Common.dll</HintPath>
    </Reference>
  </ItemGroup>

but also like this:

  <ItemGroup>
    <ProjectReference Include="..\Polyflair.Codebase\Polyflair.Codebase.SourceGeneration.Common.csproj" />
  </ItemGroup>

Inside SG everything works perfectly, but when I copy dll inside Unity, I got this error that it can’t find Common

The only solution would be to use strings instead of enum, but in my opinion it’s hacky solution. If I won’t find anything else, I would use it, but I really dont want to :confused:

Is referencing other assemblies inside SG not permitted at all?