将xunit与Microsoft.AspNetCore.Mvc 1.1.0一起使用时出错

时间:2016-11-07 09:03:09

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

当我将xunitMicrosoft.AspNetCore.Mvc 1.1.0一起使用时,我会收到以下错误(没有mvc就没有问题):

  

未处理的异常:System.IO.FileNotFoundException:无法加载   文件或屁股嵌入'Microsoft.DotNet.InternalAbstractions,   Version = 1.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60'

project.json

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0-*",
      "type": "platform"
    },
    "xunit": "2.2.0-beta2-build3300",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "Microsoft.AspNetCore.TestHost": "1.1.0-*",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0-*",
    "Microsoft.Extensions.Logging.Console": "1.1.0-*",
    "Microsoft.AspNetCore.Mvc": "1.1.0-*"
  },
  "tools": {
    "Microsoft.DotNet.Watcher.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net451+win8"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  }
}

如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

要解决此问题,请在测试项目中添加“Microsoft.DotNet.InternalAbstractions”:“1.0.0” .json:

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0-*",
      "type": "platform"
    },
    "xunit": "2.2.0-beta2-build3300",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "Microsoft.AspNetCore.TestHost": "1.1.0-*",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0-*",
    "Microsoft.Extensions.Logging.Console": "1.1.0-*",
    "Microsoft.AspNetCore.Mvc": "1.1.0-*",

    "Microsoft.DotNet.InternalAbstractions": "1.0.0"
  },
  "tools": {
    "Microsoft.DotNet.Watcher.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net451+win8"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  }
}