ASP.NET Core 1.0 (vNext) 中的引用库

编程入门 行业动态 更新时间:2024-10-25 23:38:38
本文介绍了ASP.NET Core 1.0 (vNext) 中的引用库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在学习 ASP.NET Core 1.0 (vNext).考虑到这一点,我有一个结构如下的解决方案:

I am learning ASP.NET Core 1.0 (vNext). With that in mind, I have a solution that is structured like this:

MySolution src MyLibrary MyClass.cs project.json MyWebSite Startup.cs project.json

我使用 dnu build 从命令行成功编译了 MyLibrary.我运行了生成 MyLibrary.1.0.0.nupkg 的 dnu pack.还有两个文件夹:dnx451 和 dnxcore50,它们都包含 MyLibrary.1.0.0.dll.我想在 MyWebSite 中使用 MyLibrary,但是,我很困惑.

I am successfully compiling MyLibrary from the command-line using dnu build. I ran dnu pack which generated MyLibrary.1.0.0.nupkg. There are also two folders: dnx451 and dnxcore50 which both contain MyLibrary.1.0.0.dll. I want to use MyLibrary in MyWebSite, however, I'm confused.

  • 如何将MyLibrary包含"到MyWebSite 中?我是否手动复制 .dll 文件?如果有,是哪一个?我应该改用 nupkg 文件吗?这是一个私有程序集,我不想通过 NuGet 全局发布它.
  • 我在 MyWebSite/project.json 中放什么来引用 MyLibrary 程序集?
  • How do I "include" MyLibrary into MyWebSite? Do I manually copy over the .dll file? If so, which one? Should I use the nupkg file instead? This is a private assembly, I do not want to publish it globally via NuGet.
  • What do I put in MyWebSite/project.json to reference the MyLibrary assembly?
  • 推荐答案

    如果不想与解决方案之外的其他人/项目共享包,则不必将包发布到 NuGet.您可以直接从源代码中引用包.

    You don't have to publish the package to NuGet if you don't want to share it with other people/projects outside of your solution. You can just reference the package directly from source.

    但是,如果这仍然不适合您,那么您有三个选择:

    However, if that still doesn't work for you then you have three options:

  • 使用 Roslyn 进行内部化.示例:project.json 和 实际代码
  • 您可以直接引用来源.示例 project.json
  • 创建构建时依赖项.示例 project.json 和 包的实际代码
  • Internalize using Roslyn. Example: project.json and the actual code
  • You can reference the sources directly. Example project.json
  • Create a build time dependency. Example project.json and actual code for the package
  • 更多推荐

    ASP.NET Core 1.0 (vNext) 中的引用库

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

    发布评论

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

    >www.elefans.com

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