Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net core 1.0 visual studio referencing external dll

Tags:

c#

.net

asp.net

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 Core Projects only support Referencing .Net Framework assemblies in this release To Reference other assemblies they need to be included in nuget package and reference that package"

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

like image 909
lilpug Avatar asked Jul 04 '16 11:07

lilpug


1 Answers

For referencing external dll in .net core you need to create you own nuget package.

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]

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>

Now create .nupkg file and install this package in your project.

Hope this solution works for you.

like image 138
Ashish Rastogi Avatar answered Sep 22 '22 15:09

Ashish Rastogi