我希望为 netstandard1.6 库使用测试框架。我试着关注和编辑Getting started with xUnit.net (.NET Core / ASP.NET Core)没有成功。按照 xUnit 的教程在 VS 2015 Update 3 RTM 上使用 dotnetcore lib 和我的 project.json 文件重现错误。
项目.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-*",
"testRunner": "xunit",
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}
关于c# - 使用 xUnit 处理 netstandard1.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38120169/