Can I use ASP.NET Core targeting only .NET 4.6.1?

You can run ASP.NET Core on top of .NET Core 1.0, or .NET Framework 4.5.1+. Since “ASP.NET Core” is really just a set of NuGet packages, you can install them into a project targeting either framework.

For example, a .NET Core project would look like this:

  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    }
  },
  "frameworks": {
    "netcoreapp1.0": { }
  }

While a .NET Framework project would look like (in the case of .NET 4.6.1):

  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.0"
  },
  "frameworks": {
    "net461": { }
  }

This works because the Microsoft.AspNetCore.Mvc package has targets for both .NET Framework 4.5.1 and .NET Standard Library 1.6.

It’s also possible to build for both frameworks from one project:

  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.0",
  },
  "frameworks": {
    "net461": { },
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      }
    }
  }

In this case, note that the Microsoft.NETCore.App dependency is moved inside of the frameworks section. This is necessary because this dependency is only needed when building for netcoreapp1.0, not net461.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)