I have a dependency problem integrating three .NET projects. Here goes:
I have 3 different projects:
- Project A
- Project B
- Project C
In two separate solutions:
- Solution 1 contains Project A and Project B
- Solution 2 contains Project C
Now these three Project B and C both reference Project A:
- Project B uses a
ProjectReference
for that - Project C uses a
PackageReference
for that
So far so good.
Now I want to use Project C inside Project B, so I want to create a NuGet package out of project C and use a PackageReference
to that in Project B.
So we have:
Project B ------PackageReference----> Project C
| |
| ProjectReference |
| |
| |
\/ |
Project A <--------PackageReference---------
Still everything builds.
Now when I write a function in Project B that comes from Project C, that uses a Project A type as a parameter I get a compile error. Example of a piece of code I wrote in Project B:
var foo = ProjectCFunction( ProjectAEnum );
Results in:
Error CS0012 The type 'ProjectAEnum' is defined in an assembly that is not referenced. You must add a reference to assembly 'ProjectA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d706911480550fc3'.
I only get this error when calling a Project C function that also has a Project C type in it's public signature. If I don't everything is fine, and everything runs smoothly. Which feels weird.
Also, I have considered splitting Solution 1 up, and having a solution for each project and using only PackageReferences
between the three projects. But this requires a huge effort, and refactoring, and will require a shift in my team's way of working.
Another consideration was to add Project C to Solution 1 and using only ProjectReferences
between the three. But this doesn't feel good as well, since both solutions have very different release cycles.
Does anyone know of a third option? Would really appreciate it.