问题描述
随着.net核心的发布,我一直在尝试构建一个简单的项目,但是,每当我尝试在项目中添加dll引用时,我都会收到以下消息
with the release of the .net core i have been trying to build a simple project, however whenever i try and add a dll reference in my project i get the following message
.Net核心项目仅支持在此版本中引用.Net Framework程序集。要引用其他程序集,需要将它们包含在nuget程序包中并引用该程序包。
我在RC2中收到了此消息,但在RC1中却没有,是否还有其他人遇到此问题,并且有人知道如何解决吗?除了git问题票证之外,我没有找到与此相关的任何内容
i was getting this message in RC2 but not in RC1, is anyone else having this issue and does anyone know how to resolve it? i have not been able to find anything relating to this other than a git issue ticket https://github.com/aspnet/Home/issues/1612
推荐答案
要在.net核心中引用外部dll,您需要创建自己的nuget软件包。
For referencing external dll in .net core you need to create you own nuget package.
NuGet文档显示了如何从dll创建软件包:。您可以将该nuget包放在本地文件夹中并将其用作提要:[
The NuGet docs show how to create a package from a dll:https://docs.nuget.org/create/hosting-your-own-nuget-feeds . You can put that nuget package in a local folder and use that as a feed: [https://docs.nuget.org/create/hosting-your-own-nuget-feeds]
为此,您需要编辑nuspec文件,并在nuspec文件中添加以下代码。
For this you need to edit the nuspec file and add the following code in the nuspec file.
<package>
*******--Some code--*****
<metadata>
<references>
<reference file="xxx.dll"/>
</references>
</metadata>
<--For addig reference of external dll-->
<files>
<file src="path\*.dll" target="lib\netCoreApp1.0"/>
</files>
现在创建.nupkg文件并
Now create .nupkg file and install this package in your project.
希望此解决方案对您有用。
Hope this solution works for you.
这篇关于.net核心1.0 Visual Studio引用外部dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!