.net – C# solution with missing project references unexpectedly compiles


I have the following scenario of project references in a C# solution, such that:

  • Project A references Project B
  • Project A references Project C
  • Project B references Project C

This solution compiles fine.

Now I remove the reference from Project A to Project C and it still compiles! It’s like Project A is indirectly referencing Project C though Project B, i.e.:

  • Project A references Project B
  • Project B references Project C

Is that how project referencing works? Now in Project A I can mysteriously use classes etc from Project C indirectly through Project B.

I’m developing with Visual Studio 2022 on Windows 11 with projects targeting .Net Framework 4.7.2

This isn’t just a case of weirdly working on a local machine, as the same solution also compiles as part of a Jenkins CI/CD pipeline.

Leave a Reply

Your email address will not be published. Required fields are marked *