添加对程序集 .net 核心的引用 [英] Add reference to assembly .net core

查看:35
本文介绍了添加对程序集 .net 核心的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不创建 nuget 包或添加对项目的引用的情况下添加对 .Net Core 程序集的引用?

Can you add a reference to a .Net Core assembly without creating a nuget package or adding a reference to the project ?

推荐答案

是的,这是可能的,如果你在你的 csproj 中添加这样的东西:

Yes, it is possible, if you add something like this to your csproj:

<ItemGroup>
  <Reference Include="RequiredAssembly">
    <HintPath>path\to\RequiredAssembly.dll</HintPath>
  </Reference>
</ItemGroup>

请确保在构建时可以解析引用,因为只有在代码中使用时才会出现编译错误.在这种情况下,构建会打印如下警告:

Be sure that, when building, it is possible to resolve the reference, since compilation errors only when using in the code. The build prints a warning like this, in such a case:

warning MSB3245: Could not resolve this reference. Could not locate the assembly "RequiredAssembly". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

与此相关的两个很好的答案:

Two good answers related with this:

但是,您仍然可以使用 nuget 包,即使是在本地 - 设置本地 nuget 存储库并使用它管理您的依赖项.这很简单:)

However, you could still use a nuget package, even locally - setup a local nuget repository and manage your dependencies using it. It is pretty straightforward :)

这两个链接贯穿整个过程:

These two links walk through the process:

这篇关于添加对程序集 .net 核心的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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