4

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?

1
  • 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 dependency Commented May 23, 2016 at 6:53

3 Answers 3

5

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

Sign up to request clarification or add additional context in comments.

4 Comments

You mean i should not use a class library for my tests but should use a console application?
@Thomas I'm trying to create a test project that uses xUnit. I created a Console Application (.NET Core) RC2, but when adding the xUnit package "xunit": "2.2.0-beta1-build3239", it shows this error: Compiling OmniXaml.Tests.NetCoreApp for .NETCoreApp,Version=v1.0 1>D:\Source\Repos\OmniXAML\OmniXaml.Tests.NetCoreApp\project.json(12,37): error NU1002: The dependency xunit.abstractions 2.0.0 does not support framework .NETCoreApp,Version=v1.0.
For RC2 the following xunit packages work: xunit:2.1.0 and "dotnet-test-xunit": "1.0.0-rc2-build10015" (xunit.github.io/docs/getting-started-dotnet-core.html)
I think the issue is you are missing the portable+net45 import. (see answer below)
3

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"
            ]
        }
    }
}

Comments

2

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"
      ]
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.