简体   繁体   中英

Possibility to reference "traditional" (old) .net libraries from .net core applications

There are a bit confusing information about the backward referencing possibility from .net core applications (eg ASP.Net Core) to the commonly used .net framework libraries. I got the following impression now:

  1. If you are using "netcoreapp1.0", then you cannot reference an ordinary library at all.
  2. If you are using eg "net451", then you can reference it, but you have to wrap it first in a nuget package with corresponding tag.

Does this sound correct?

PS I was thinking that perhaps in case 1 decompiling to IL and recompiling back as "netcoreapp1.0" or "netstandard1.6" or some other voodoo can help?

PPS As mentioned in comments it's possible to reference ordinary class library project that can in turn reference the library, but that will mean you have to wrap everything that is in the library, so depends a lot if this can be used.

For the moment this is not possible.

You have 3 options:

  1. attempt to convert your old project into a portable class library (PCL), which can then be referenced by your .net core app.
  2. wrap your project into a nuget package (you already mentioned that)
  3. Add the project as a class library (mentioned in the comments), but according to that SO answer and that GitHub thread it does not seem easy to make it work.

EDIT on 20-03-2017 : Just came across this post : It seems now possible to have your .NET Core app target .NET 4.6 by changing the .csproj, UNTESTED (yet)

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

to

  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>

then dotnet restore followed by dotnet run

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM