xunit icon indicating copy to clipboard operation
xunit copied to clipboard

Module reference error when targetting DNX 4.5.1 (xunit 2.1.0, DNX beta8)

Open Aerendel opened this issue 11 years ago • 4 comments

After upgrading to DNX beta8 and xUnit 2.1.0 I am getting the following error when my test project is targetting DNX 4.5.1:

CS0012 C# The type '' is defined in an assembly that is not referenced# You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Compiling for DNXCore50 works fine, but I can't build for DNX451 anymore. Note that this works for me if I switch back to dnx beta5 and xunit 2.1.0-beta3.

Screenshot attached.

untitled

Aerendel avatar Nov 04 '15 21:11 Aerendel

Ok, after hours of experimenting I figured it out. This issue happens when the project.json dependencies reference xunit but NOT xunit.runner.dnx.

This will build:

  "dependencies": {
    "xunit": "2.1.0",
    "xunit.runner.dnx": "2.1.0-beta6-build191"
  }

However this will not:

  "dependencies": {
    "xunit": "2.1.0"   
  }

Definitely looks like a bug to me. although this makes it less of a big deal since there's not much point in not including the runner dependency, but I think it's definitely remarkable enough to take a look at as it did waste about 8 hours of my time today :)

Aerendel avatar Nov 05 '15 05:11 Aerendel

Any news on this? I am writing an extension to xunit that only needs xunit.core and I am having the exact same problem. I guessing that xunit.runner.dnx pulls in some missing dependency and suddenly everything just starts to work. The thing is that I don't want to take a dependency on the runner in my extension. I suspect that the error message complaining about system.runtime 4.0.0.0 is somewhat misleading and that it might be another dependency that is missing and should be brought in when referencing xunit.core.

seesharper avatar Dec 18 '15 08:12 seesharper

I believe this to be a DNX bug, not an xUnit.net bug. We will reevaluate it once dnx has been replaced by dotnet.

bradwilson avatar Dec 31 '15 16:12 bradwilson

I'm having the same issue. @Aerendel's trick of adding xunit.runner.dnx doesn't work for me, because I'm targeting net45. Adding xunit.runner.visualstudio doesn't solve the issue. Is there anything else I could try?

thomaslevesque avatar Jan 14 '16 20:01 thomaslevesque