c# – 使用xUnit处理netstandard1.6

前端之家收集整理的这篇文章主要介绍了c# – 使用xUnit处理netstandard1.6前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望使用netstandard1.6库的测试框架.我试图关注并编辑 Getting started with xUnit.net (.NET Core / ASP.NET Core)但没有成功.使用我的project.json文件在VS 2015 Update 3 RTM上使用带有dotnetcore lib的xUnit教程重现错误.

project.json:

{
  "version": "1.0.0-*","testRunner": "xunit","dependencies": {
    "NETStandard.Library": "1.6.0","xunit": "2.2.0-beta2-build3300","dotnet-test-xunit": "2.2.0-preview2-build1029"
  },"frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  },"runtimes": {
    "win10-arm": {},"win10-arm-aot": {},"win10-x86": {},"win10-x86-aot": {},"win10-x64": {},"win10-x64-aot": {}
  }
}

错误

Severity    Code    Description
Error       NU1002  The dependency dotnet-test-xunit 2.2.0-preview2-build1029 does not support framework .NETStandard,Version=v1.0

我可以降级到dotnet-test-xunit 2.2.0-preview2-build1029支持的.netstandard版本吗?有没有任何已知的工作来使用xUnit?

由于我是一个新的project.json和dotnetcore,我可能会错过一些有用的东西.

解决方法

这对我有用.现有的xunit版本似乎还不支持netstandard 1.6库.尝试将项目json更改为 xunit site中提供的内容.这也假设您创建了一个.net核心库项目
{
  "version": "1.0.0-*","dependencies": {
    "xunit": "2.2.0-beta2-build3300","frameworks": {
    "netcoreapp1.0": {
       "dependencies": {
          "Microsoft.NETCore.App": {
             "type": "platform","version": "1.0.0"
           }
         }
      }
   }
}
原文链接:https://www.f2er.com/csharp/243345.html

猜你在找的C#相关文章