Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xunit does not compile with ASP.NET Core RC2

I created an ASP.NET Core RC2 Class Library, named MyHelpers, and got the following on project.json:

"dependencies": {
  "NETStandard.Library": "1.5.0-rc2-24027",
},

"frameworks": {
  "netstandard1.5": {
    "imports": [
      "dnxcore50",
      "portable-net452+win81"
    ]
  }
}

I then created an ASP.NET Core RC2 Class Library for testing, named MyHelpersTests, and got the following in project.json:

"testRunner": "xunit",

"dependencies": {
  "NETStandard.Library": "1.5.0-rc2-24027",
  "xunit": "2.2.0-beta1-build3239",
  "dotnet-test-xunit": "1.0.0-rc2-build10015",
  "MyHelpers": "1.0.0"
},

"frameworks": {
  "netstandard1.5": {
    "imports": [
      "dnxcore50",
      "portable-net452+win81"
    ]
  }
}   

When I compile it I get the error:

Package dotnet-test-xunit 1.0.0-rc2-build10015 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package dotnet-test-xunit 1.0.0-rc2-build10015 supports:

- net451 (.NETFramework,Version=v4.5.1) - netcoreapp1.0 (.NETCoreApp,Version=v1.0) One or more packages are incompatible with .NETStandard,Version=v1.5.

What am I missing?

like image 263
Miguel Moura Avatar asked Dec 24 '22 05:12

Miguel Moura


1 Answers

Actually your test project cannot be a netstandard1.5 library but a netcoreapp1.0 application (like also stated in the error message and the xunit introduction page). The test assembly need to executable and need a Main() (which is provided by xunit). netstandard1.5 is a subset of netcoreapp1.0.

I think you also have to change your dependency to "Microsoft.NETCore.App":"1.0.0-rc2-3002702".

like image 127
Thomas Avatar answered Dec 28 '22 09:12

Thomas