Solving error “Microsoft.NETCore.App 1.0.0 does not support framework .NETFramework,Version=v4.6.1”

被刻印的时光 ゝ 提交于 2019-11-30 11:43:45

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:

  • 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"
         ]
      }
   }

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.

I referenced .net core class library in .net 4.6.1 by changing the following.

Before I was getting this error when trying to reference the .net core from .net 4.6.1

Fix:

Original

    {
    "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Interop.SHDocVw.dll": "1.1.0",
    "Microsoft.mshtml.dll": "7.0.3300.1"
    },

    "frameworks": {
    //"net461": {},
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8",
        "net461"
      ]
    }
   },

    "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ]
    }
   }

Corrected

    {
     "dependencies": {
        "Interop.SHDocVw.dll": "1.1.0",
        "Microsoft.mshtml.dll": "7.0.3300.1"
     },

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

    "scripts": {
        "prepublish": [ "bower install", "dotnet bundle" ]
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!