Search code examples
c#asp.net.netasp.net-corednx

Why are my DNX-based unit tests unable to resolve System dependencies?


I'm writing up a DNX-based portable class library that I want to be used on all platforms. Here is its project.json:

{
    "title": "flavor.net",

    "dependencies": {
        "Be.IO": "1.0.0"
    },

    "frameworks": {
        ".NETPortable,Version=v4.5,Profile=Profile259": {
            "frameworkAssemblies": {
                "System.Collections": { "type": "build" },
                "System.IO": { "type": "build" },
                "System.Linq": { "type": "build" },
                "System.Runtime": { "type": "build" }
            }
        }
    }
}

Here is the unit tests' project.json (I'm using the xUnit.net testing framework):

{
    "dependencies": {
        "flavor.net": "",
        "VideoLibrary": "1.3.3",
        "xunit": "2.1.0",
        "xunit.runner.dnx": "2.1.0-rc1-build204"
    },
    "commands": {
        "test": "xunit.runner.dnx"
    },
    "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
    }
}

When I attempt to build this, I'm getting several errors saying things like The dependency fx/System.Collections could not be resolved for all of the System dependencies in the first file. The weird thing is, that project itself seems to be building fine, but it's the unit test project that is causing errors.

Here's a screenshot for extra clarity:

Why is this happening and what can I do to fix it? I'm using VS 2015 Update 1 and my DNX version is 1.0.0-rc1-update1.


Solution

  • You're missing those references in the test project's project.json file. Example : https://github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json