12

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

10
  • How are you adding the dll reference in your project? Can you share a code sample? Commented Jul 4, 2016 at 11:40
  • can't really add the reference code as its more actions, i right click on the references -> add reference... -> browse then point to the dll i require thats 4.6, then once its in the list and i click ok i get the above message Commented Jul 4, 2016 at 11:45
  • 1
    look at this stackoverflow.com/questions/30985426/… Commented Jul 4, 2016 at 11:59
  • 1
    @lexLi excuse me? Aside from your inappropriate and unhelpful comment, we are talking about adding external dll references, what happens if I don't even have the source code for one of these dll libraries how am i going to create a separate class library project in the same solution and still get the dll to reference correctly in the .net core project? adding an external dll library should not require an additional class library project just to add the reference. I think it’s a bug possibly stackoverflow.com/questions/38107573/… Commented Jul 4, 2016 at 12:42
  • 3
    @LexLi That's a pretty immature response. Proxying a reference by creating another project is just a bit silly, really. Adding external references was prevented in RC2, but it was supposed to be re-enabled for released of .NET Core. Are you saying it is 'right' for MS to not allow referencing DLL's that aren't in NuGet? There is no point in clogging up NuGet with packages that only 1 person/ a small team is going to use. Commented Jul 4, 2016 at 15:39

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.