1

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.

  • What about switching to PackageReference between A and C instead of ProjectReference? I cannot imagine how a combination of Project- and PackageReference should work: assuming both A and C have version 1.0.0 and B references C.1.0.0. Now *project* (but not the package) A gets updated - what should B do? It has to use the newest project since projects are not versioned - but the implicit package version of A is still 1.0.0 – mu88 Jan 27 '22 at 15:39
  • I notice you've got a non-null public key token, which is used as part of the assembly identity. If you project reference Project A, does the dll have the same public key token as the dll in the NuGet package? See https://stackoverflow.com/a/24136074/2066474 for how to check – rbennett485 Jan 27 '22 at 21:00
  • I just checked, public tokens are the same.. – Marten Smits Jan 31 '22 at 09:50
  • Have you found a solution for your problem? – Michal Sznajder Mar 31 '23 at 07:47

0 Answers0