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

前端 未结 2 1118
青春惊慌失措
青春惊慌失措 2021-01-02 00:08

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

2条回答
  •  一向
    一向 (楼主)
    2021-01-02 00:33

    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.

提交回复
热议问题