Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...