Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

c# - .net core 1.0 visual studio referencing external 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 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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
etCoreApp1.0"/>
 </files>

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

Hope this solution works for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...