Visual Studio Test Runner complains that it cannot find "xunit.core, Version = 2.x.0"

I am trying to create a new PCL library (along with a new Universal Windows Application) and I created a new project to start writing my unit tests using xUnit. I've added nuget links to xunit

as well xunit.runner.visualstudio

. I am using Visual Studio 2015 RTM as well as Resharper 9.1 and worrying about them gives me a similar error when trying to run or detect unit tests. This is from visual studio:

------ Start test started ------

[xUnit.net 00: 00: 00.2661814] Skipping: WinBlur.NewsBlurClient.Tests (Could not find dependent assembly "xunit.core, Version = 2.1.0")

[xUnit.net 00: 00: 00.2235684] Skipping: WinBlur.NewsBlurClient.Tests (Could not find dependent assembly "xunit.core, Version = 2.1.0")

========== Open test: 0 found (0: 00: 00.6920785) ==========

This output shows an attempt to use the latest 2.1 beta, but I have also tried the current version (2.0.0) and get the same result.

Here's my project.json

file:

{
  "supports": {
    "net46.app": {},
    "uwp.10.0.app": {}
  },
  "dependencies": {
    "Microsoft.NETCore": "5.0.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.0",
    "xunit": "2.0.0",
    "xunit.core": "2.0.0",
    "xunit.assert":  "2.0.0",
    "xunit.runner.visualstudio": "2.0.1"
  },
  "frameworks": {
    "dotnet": {
      "imports": "portable-net452+win81"
    }
  }
}

      

When I added the nuget reference for xunit it did not initially add dependencies for xunit.core

and xunit.assert

, so I added them myself to see if it helped, but no luck.

+3


source to share


2 answers


xUnit.net is now split into modern PCLs.



The error is that modern PCLs (or any class library that uses project.json instead of packages.config) do not copy associated DLLs. This is a bug in Visual Studio support for project.json with class libraries and needs to be fixed by the Microsoft team.

+2


source


A workaround (for some libraries at least) is that you can add these properties to your project file:

<PropertyGroup>
    <CopyNuGetImplementations>true</CopyNuGetImplementations>
    <PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

      



After that, xunit works with project.json. At least for me.

+3


source







All Articles