如何在asp.net vNext中使用现有代码 [英] How to use existing code in asp.net vNext

查看:65
本文介绍了如何在asp.net vNext中使用现有代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用asp.net vNext播放一些内容.

Trying to play a bit with asp.net vNext.

假设我有 MyCode.dll 程序集,其中包含一些我想在我的be vNext项目中使用的代码.如何引用现有的.net 4.5程序集?

Let's say I have MyCode.dll assembly with some code I have and want to use in my be vNext project. How can I reference existing .net 4.5 assembly?

我已经将其打包到nuget包中,然后通过使用本地feed将其添加到vNext项目中.还使用了 kpm restore 来实际下载软件包.

I've packed it into nuget package, and then by using local feed add it to vNext project. Also used kpm restore to actually download the package.

似乎软件包已成功添加,但是没有 MyCode.dll 中的代码可用,因此intelliSence根本不使用它,并且构建抛出类型或名称空间应该找不到

It looks like package added successfully, but no code from MyCode.dll available, it's simply not used by intelliSence and build throw Type or namespace chould not be found

我可以将代码从 MyCode.dll 移到asp.net 5类库,但是我需要重用其他项目也使用过的现有dll,例如asp.net的旧版本等.

I could move code from MyCode.dll to asp.net 5 class library, but I need to reuse existing dll that also is used by other projects, like old versions of asp.net etc.

推荐答案

我的解决方法是添加一个本地nuget服务器,并通过指定目标的倍数版本来正确指定,打包程序集并将其推入nuget服务器.NET,如aspnetcore5,aspnet5和net45.创建程序集的规范文件时,请不要忘记为每个版本都包括它们的相应依赖项.

My work around was to add a local nuget server and correctly spec, pack and push the assembly to the nuget server by doing that you can target multiples version of .NET like aspnetcore5, aspnet5 and net45. When creating the specification file of the assembly don't forget to include their corresponding dependencies for each version.

要创建本地服务器,请参见说明此处

To create a local server please see instruction here

请参阅示例规范.

<dependencies>
  <group targetFramework="net45">
    <dependency id="Newtonsoft.Json" version="6.0.6" />
  </group>
  <group targetFramework="aspnet50">
    <dependency id="Newtonsoft.Json" version="6.0.6" />
    <dependency id="System" version="4.0.0.0" />
    <dependency id="System.Core" version="4.0.0.0" />
    <dependency id="Microsoft.CSharp" version="4.0.0.0" />
    <dependency id="mscorlib" version="4.0.0.0" />
  </group>
  <group targetFramework="aspnetcore50">
    <dependency id="Newtonsoft.Json" version="6.0.6" />
    <dependency id="System.Runtime" version="4.0.20-beta-22231" />
    <dependency id="System.Collections" version="4.0.10-beta-22516" />
  </group>
</dependencies>

这篇关于如何在asp.net vNext中使用现有代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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