xnet在dotnet cli项目上

时间:2016-04-18 15:56:46

标签: asp.net-core xunit .net-core

我正在尝试在dotnet cli项目上设置xunit测试。我意识到这是支持的早期阶段。现在,我无法恢复包裹。以下是我的project.json

{
  "version": "1.0.0-*",
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-3002392"
    },
    "xunit": "2.1.0-*",
    "dotnet-test-xunit": "1.0.0-dev-*"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "portable-net45+wp80+win8+wpa81+dnxcore50"
      ]
    }
  },
  "testRunner": "dotnet-test-xunit"
}

运行dotnet restore后,我收到以下错误:

Package xunit.assert 2.1.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package xunit.assert 2.1.0 supports:
  - dotnet (.NETPlatform,Version=v5.0)
  - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
Package xunit.runner.reporters 2.1.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package xunit.runner.reporters 2.1.0 supports:
  - dnx451 (DNX,Version=v4.5.1)
  - dotnet (.NETPlatform,Version=v5.0)
  - net45 (.NETFramework,Version=v4.5)
Package Microsoft.Extensions.Logging.Abstractions 1.0.0-rc2-16040 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.Extensions.Logging.Abstractions 1.0.0-rc2-16040 supports:
  - dotnet5.4 (.NETPlatform,Version=v5.4)
  - net451 (.NETFramework,Version=v4.5.1)
  - netcore50 (.NETCore,Version=v5.0)
Package Microsoft.DiaSymReader 1.0.6 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.DiaSymReader 1.0.6 supports:
  - net20 (.NETFramework,Version=v2.0)
  - portable-net45+win8 (.NETPortable,Version=v0.0,Profile=Profile7)
Package Microsoft.Extensions.FileSystemGlobbing 1.0.0-rc2-15996 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.Extensions.FileSystemGlobbing 1.0.0-rc2-15996 supports:
  - dotnet5.4 (.NETPlatform,Version=v5.4)
  - net451 (.NETFramework,Version=v4.5.1)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.

Feeds used:
    https://www.myget.org/F/dotnet-core/api/v3/index.json
    https://api.nuget.org/v3/index.json
    https://www.myget.org/F/coreclr-xunit/api/v2
    https://www.myget.org/F/dotnet-cli/

1 个答案:

答案 0 :(得分:4)

您指定的导入无法满足所有要求。这就是你看错的原因。

尝试将其替换为:

"imports": [
    "portable-net451+win8",
    "dnxcore50"
]

另外,xunit runner应该是“xunit”而不是“dotnet-test-xunit”。

在此处查看示例项目:https://github.com/aspnet/dotnet-watch/blob/46d4c6edcb374060b4e8ebf83e3ccd399f8f61ae/test/dotnet-watch.FunctionalTests/project.json