gpt4 book ai didi

c# - AspNetCore “runtimes”是不受支持的框架

转载 作者:行者123 更新时间:2023-12-02 10:46:34 27 4
gpt4 key购买 nike

当尝试从新的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%"
]
}
}

最佳答案

因为测试项目被认为是控制台应用程序(即使您从未直接运行它),所以您需要引用Microsoft.NETCore.App:

"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},

“不受支持的框架”错误是一种毫无帮助的说法:“我不知道这是什么类型的项目!”

作为引用,这是我最近使用的有效的Xunit测试project.json。您不需要引用 xunit.runner.consolerunner.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"
}

关于c# - AspNetCore “runtimes”是不受支持的框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40335011/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com