Possibility to reference “traditional” (old) .net

2019-08-05 03:48发布

There are a bit confusing information about the backward referencing possibility from .net core applications (e.g. 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 e.g. "net451", then you can reference it, but you have to wrap it first in a nuget package with corresponding tag.

Does this sound correct?

P.S. 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?

P.P.S. 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.

1条回答
Summer. ? 凉城
2楼-- · 2019-08-05 04:07

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

查看更多
登录 后发表回答