问题描述
我正在学习 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
intoMyWebSite
? Do I manually copy over the.dll
file? If so, which one? Should I use thenupkg
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 theMyLibrary
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) 中的引用库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!