简体   繁体   English

为什么基于DNX的单元测试无法解决系统依赖性?

[英]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. 我正在编写一个要在所有平台上使用的基于DNX的可移植类库。 Here is its project.json : 这是它的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): 这是单元测试的project.json (我正在使用xUnit.net测试框架):

{
    "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 dependency fx/System.Collections could not be resolved对第一个文件中的所有System依赖项The dependency fx/System.Collections could not be resolved诸如The dependency fx/System.Collections could not be resolved依赖项之类的内容。 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. 我正在使用VS 2015 Update 1,我的DNX版本是1.0.0-rc1-update1。

You're missing those references in the test project's project.json file. 您在测试项目的project.json文件中丢失了这些引用。 Example : https://github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json 示例: https : //github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM