4
votes

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?

3
Please note there is an bug/issue with the 1.0.0-rc2-build10015 dotnet runner. github.com/xunit/xunit/issues/843 You should use the rc from the myget feed (myget.org/F/xunit/api/v3/index.json): "dotnet-test-xunit": "1.0.0-rc3-build10019". When using it, you also additionally need "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027" as dependencyTseng

3 Answers

5
votes

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".

3
votes

This worked for me today and the whole config looks like this...

{
    "version": "1.0.0-*",

    "testRunner": "xunit",

    "dependencies": {
        "Microsoft.NETCore.App": {
            "version": "1.0.0-rc2-3002702",
            "type": "platform"
        },
        "xunit": "2.1.0",
        "dotnet-test-xunit": "1.0.0-rc2-build10025"
    },

    "frameworks": {
        "netcoreapp1.0": {
            "imports": [
                "dnxcore50",
                "portable-net45+win8"
            ]
        }
    }
}
2
votes

I think the issue is you are missing the portable+net45 import.

This is my project.json :

"frameworks": {
     "netcoreapp1.0": {
       "dependencies": {
        "Microsoft.NETCore.App": {
           "type": "platform",
           "version": "1.0.0-rc2-3002702"
        }
       },
       "imports": [
         "dnxcore50",
         "portable-net45+win8"
      ]
    }