解决错误“ Microsoft.NETCore.App 1.0.0不支持框架.NETFramework,Version = v4.6.1”。

编程入门 行业动态 更新时间:2024-10-28 21:18:56
本文介绍了解决错误“ Microsoft.NETCore.App 1.0.0不支持框架.NETFramework,Version = v4.6.1”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用 net461 引用运行的ASP.NET Core 1.0完整应用程序。现在,我试图添加另一个框架- netcoreapp1.0 。为此,我像这样更新了我的project.json:

I have an ASP.NET Core 1.0 complete application running using net461 references. Now I am trying to add another framework - netcoreapp1.0. For this, I have updated my project.json like this:

{ "userSecretsId":"", "version":"2.4.0-*", "buildOptions":{ "emitEntryPoint":true, "preserveCompilationContext":true }, "dependencies":{ "Microsoft.ApplicationInsights.AspNetCore":"1.0.0", "Microsoft.AspNetCore.Authentication.Cookies":"1.0.0", "Microsoft.AspNetCore.Diagnostics":"1.0.0", "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore":"1.0.0", "Microsoft.AspNetCore.Identity":"1.0.0", "Microsoft.AspNetCore.Identity.EntityFrameworkCore":"1.0.0", "Microsoft.AspNetCore.Mvc":"1.0.0", "Microsoft.AspNetCore.Mvc.TagHelpers":"1.0.0", "Microsoft.AspNetCore.Server.IISIntegration":"1.0.0", "Microsoft.AspNetCore.Server.Kestrel":"1.0.0", "Microsoft.AspNetCore.StaticFiles":"1.0.0", "Microsoft.EntityFrameworkCore":"1.0.0", "Microsoft.EntityFrameworkCore.SqlServer":"1.0.0", "Microsoft.Extensions.Configuration.CommandLine":"1.0.0", "Microsoft.Extensions.Configuration.FileExtensions":"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.VisualStudio.Web.BrowserLink.Loader":"14.0.0", "Microsoft.VisualStudio.Web.CodeGenerators.Mvc":"1.0.0-preview2-final" }, "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.Extensions.SecretManager.Tools":"1.0.0-preview2-final" }, "commands":{ "ef":"EntityFramework.Commands", "web":"Microsoft.AspNetCore.Server.Kestrel" }, "frameworks":{ "net461":{ }, "netcoreapp1.0":{ "imports":[ "dotnet5.6", "portable-net45+win8" ] } }, "runtimes":{ "win10-x64":{ }, "win81-x64":{ }, "win8-x64":{ }, "win7-x64":{ } }, "publishOptions":{ "exclude":[ "**.user", "**.vspscc", "wwwroot", "node_modules" ] }, "scripts":{ "prepublish":[ "npm install", "bower install", "gulp clean", "gulp min" ] } }

修改project.json后,出现此错误:

After modifying project.json, I got this error:

无法使以下项目可运行:MVC6_Full_Version (.NETCoreApp,Version = v1.0)原因:预期在包图中找不到coreclr库。请尝试再次运行dotnet restore。

Failed to make the following project runnable: MVC6_Full_Version (.NETCoreApp,Version=v1.0) reason: Expected coreclr library not found in package graph. Please try running dotnet restore again.

要解决此问题,我运行了 dotnet restore

To resolve this, I ran dotnet restore command but no luck.

然后,我添加了这个代码段:

Then, I added this block:

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

添加此块后,我遇到了另一个错误:

After adding this block, I got a different error:

代码:NU1002说明:依赖项Microsoft.NETCore.App 1.0.0 不支持框架.NETFramework,Version = v4.6.1。

Code: NU1002 Description: The dependency Microsoft.NETCore.App 1.0.0 does not support framework .NETFramework,Version=v4.6.1.

基本上,我想在我的应用程序中同时添加两个引用-.NET Framework 4.6.1和ASP.NET Core 1.0。

Basically, I want to add both references in my applications - .NET Framework 4.6.1 and ASP.NET Core 1.0.

如何我该解决这个错误吗?

How do I resolve this error?

推荐答案

使用.NET Framework或.NET Core绝对可以构建ASP.NET Core项目。您真的很接近-只需进行一些调整:

It's definitely possible to build ASP.NET Core projects using .NET Framework or .NET Core. You're really close - just a few tweaks needed:

  • 删除运行时部分,除非您打算进行本机编译(有点不寻常)
  • 将对 Microsoft.NETCore.App 的引用放在 dependencies 部分 inside 中的
  • Remove the runtimes section, unless you are intending to do native compilation (somewhat unusual)
  • Place the reference to Microsoft.NETCore.App in a dependencies section inside the netcoreapp1.0 section. I've tested the following change and it restores and compiles without errors:

project.json ... "frameworks": { "net461": { }, "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" } }, "imports": [ "dotnet5.6", "portable-net45+win8" ] } }

Microsoft.NETCore.App 依赖性仅是.NET Core所必需的,在此处添加它将确保在为该框架构建时可用。

The Microsoft.NETCore.App dependency is only required for .NET Core, and adding it here will make sure it's available when building for that framework.

此外,命令部分已被弃用,可以删除。

Also, the commands section has been deprecated and can be removed.

更多推荐

解决错误“ Microsoft.NETCore.App 1.0.0不支持框架.NETFramework,Version = v4.6.1”。

本文发布于:2023-11-05 11:43:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560749.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   框架   错误   NETCore   App

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!