You can add dependencies, it's just important, that you also add the dependencies to the project where the source generator is used:
SourceGenerator.csproj:
<ProjectReference Include="..\Dependency.csproj" />
FinalProject.csproj:
<ProjectReference Include="..\Dependency.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
And I also recommend to add "<LangVersion>latest</LangVersion>" to SourceGenerator.csproj to use new features like raw string literals.