尝试从新的DotNetCore类库导入AspNetCore MVC站点(WebApplication1)以运行某些测试时,我得到以下内容。
任何人都可以了解编译器的工作原理以及这个runtimes is not supported error is coming
的原因吗?希望能够解决这个问题。
错误:
NU1008 "runtimes" is an unsupported framework.
Taskily.Tests
%src%\Taskily.Tests\project.json 19
%SRC%\ Taskily.Tests \ project.json
{
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.AspNetCore.TestHost": "1.1.0-preview1-final",
"WebApplication1": "1.0.0-preview2-003131",
"xunit": "2.2.0-beta3-build3402",
"xunit.runner.console": "2.2.0-beta3-build3402",
"xunit.runner.visualstudio": "2.2.0-beta3-build1187"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"testRunner": "xunit"
}
%SRC%\ global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
%SRC%\ WebApplication1 \ project.json
{
"userSecretsId": "aspnet-WebApplication1-19b75b8b-b10e-4fea-94e8-17c9f955732e",
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.1",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build",
"imports": [ "portable-net45+win8+wp8+wpa81" ]
},
"Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.1",
"Microsoft.AspNetCore.Authentication.OAuth": "1.0.0",
"Newtonsoft.Json": "9.0.2-beta1"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"copyToOutput": [
"ssl/*"
],
"define": [ "DEBUG" ]
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config",
"ssl"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
}
}
答案 0 :(得分:1)
由于测试项目被视为控制台应用程序(即使您从未直接运行),因此您需要引用Microsoft.NETCore.App
:
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
“不支持的框架”错误是一种相当无益的说法:“我无法弄清楚这是什么类型的项目!”
作为参考,这是我最近使用过的一个有效的Xunit测试项目.json。您不应该需要引用xunit.runner.console
或runner.visualstudio
才能使用Test Explorer。
{
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"xunit": "2.1.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
},
"testRunner": "xunit"
}