如何在asp.net vNext中使用现有代码

编程入门 行业动态 更新时间:2024-10-27 14:31:45
本文介绍了如何在asp vNext中使用现有代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

Trying to play a bit with asp vNext.

假设我有 MyCode.dll 程序集,其中包含一些我想在我的be vNext项目中使用的代码.如何引用现有的 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 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 5类库,但是我需要重用其他项目也使用过的现有dll,例如asp的旧版本等.

I could move code from MyCode.dll to asp 5 class library, but I need to reuse existing dll that also is used by other projects, like old versions of asp 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中使用现有代码

本文发布于:2023-06-10 16:25:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/615001.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   如何在   net   asp   vNext

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!