可能提及“传统”字样。 .net核心应用程序中的(旧).net库 [英] Possibility to reference "traditional" (old) .net libraries from .net core applications

查看:84
本文介绍了可能提及“传统”字样。 .net核心应用程序中的(旧).net库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于从.net核心应用程序(例如ASP.Net Core)到常用的.net框架库的向后引用可能性的信息有些令人困惑。我现在得到以下印象:

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. 如果您使用的是 netcoreapp1.0,则根本无法引用普通库。 / li>
  2. 如果您使用例如 net451,则可以引用它,但必须先将其包装在带有相应标签的nuget包中。

听起来正确吗?

PS我在想,如果将情况1反编译为IL并重新编译为 netcoreapp1.0或 netstandard1.6或其他一些巫毒教,可能会有所帮助?

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。如评论中所述,可以引用普通的类库项目,而该类项目又可以引用该库,但这将意味着您必须包装库中的所有内容,因此在很大程度上可以使用它。

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.

推荐答案

目前无法实现。

您有3种选择:


  1. 尝试将您的旧项目转换为可移植类库(PCL),然后您的.net核心应用即可引用该类。

  2. 将您的项目包装到一个nuget包中(您已经提到过)

  3. 将项目添加为类库(在注释中提到),但要符合该答案该GitHub线程使其难以工作。

  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.

在20-03-2017上编辑:
刚遇到这篇文章:现在似乎可以通过更改.csproj(尚未完成)来使.NET Core应用程序以.NET 4.6为目标。

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>

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

然后 dotnet还原然后是 dotnet运行

这篇关于可能提及“传统”字样。 .net核心应用程序中的(旧).net库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆