-1

One of my colleagues has added a test project to the master branch that includes a Moq reference. Its not even busing used at the time, simply having the reference causes the build and website to fail:

enter image description here

I called it a pseudo random issue in the title because I've also have that happen with the same error but:

System.Buffers

Once it's set, it's pretty consistent, so no clue what the trigger is to throw on a different library.

If I remove the website from the solution, the code builds correctly, but the website still shows the issue in the browser (as you would expect, I guess).

If I remove Moq and all of the traces adding that exist for the dependency (and it's children), the build is working again


Another reason why I call it a pseudo random issue is that I suspect that what I see is a symptom of the issue. Not the issue itself. It just so happens to trigger on System.Runtime.CompilerServices.Unsafe or whatever.


Any ideas / tips on what I can do to:
  1. Find the actual issue
  2. Come up with a solution?

PS: In case it could be important, we are on a deterministic build, not the default.

Spikee
  • 3,967
  • 7
  • 35
  • 68
  • 1
    If you build just the website, does it still happen? I ask because if you explicitly build the website it shouldn't try and build any test projects and so that should help isolate the issue. – Shafiq Jetha Jan 12 '21 at 00:45
  • If you're going to downvote, please elaborate why. – Spikee Jan 12 '21 at 07:23
  • @ShafiqJetha I get why you ask that, but it's not possible because of the way the solution is set up. All dlls end up in the same bin folder , so even when not running in a context where the tests wouldn't be called, the dll is still there. – Spikee Jan 12 '21 at 07:24
  • I feel like that might be the issue. You have test-specific DLLs alongside production DLLs, and some reference is getting incorrectly loaded. The other option could be to allow unsafe code in your web project and see if that solves the issue, but that might not be an ideal solution. – Shafiq Jetha Jan 12 '21 at 13:34
  • @ShafiqJetha Yeah, I fear you're right. Thanks for your insights. – Spikee Jan 13 '21 at 07:27

1 Answers1

1

With more time passed it's clear that its an architectural fault. A thorough restructuring is needed to fix that so sadly no easy answer can be provided for this.

Spikee
  • 3,967
  • 7
  • 35
  • 68