Use full .NET Framework with existing ASP.NET Core project

We have an ASP.NET Core web application currently running on .NET Core, which now needs to reference internal libraries which were built for and will only run on the full .NET Framework.

As per the documentation:

ASP.NET Core apps can run on .NET Core or on the full .NET Framework.

...What steps are needed to change an existing ASP.NET Core project to run on the full .NET Framework?

I can't seem to find anything in the documentation or in the Visual Studio tooling to switch between .NET Core and the full .NET Framework.


It should be enough to change your project.json by removing the netcoreapp1.0 section inside frameworks and replacing it with net4xy , where x and y depend on the version of .Net Framework you want to target, eg net461 for .Net 4.6.1.

For example, before:

"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.0.1"
      }
    },
    "imports": "dnxcore50"
}

After:

"frameworks": {
  "net461": {}
}

I guess that you have to pick up a right project type when defining this ASP.NET Core application. When selecting the project type, you can choose if you want to have .NET Core that runs everywhere, or .NET Core that runs on .NET Framework (you select the version from the drop down list on the top-left of the dialog).

Those should be a different options in your new project dialog.

This way, in your references (project.json) you will see only .NET Framework of selected version and framework dependencies which you choose (you normally add the .NET Framework reference as for any other project type).

There's a lot going on in this topic as project.json is being abandoned by Microsoft on favour of MSBuild xml files.

There's also a nice post of Scott Hanselman about this topic here:http://www.hanselman.com/blog/HowToReferenceAnExistingNETFrameworkProjectInAnASPNETCore10WebApp.aspx

Please also note, that if you want to run a .NET Core application that runs anywhere, you can't reference full .NET Framework libraries (only .NET Standard).

链接地址: http://www.djcxy.com/p/21296.html

上一篇: 将ASP.NET核心部署到Azure不会迁移数据库

下一篇: 在现有的ASP.NET Core项目中使用完整的.NET Framework