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

lilpug
  • 141
  • 1
  • 6
  • How are you adding the dll reference in your project? Can you share a code sample? – timothyclifford Jul 04 '16 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 – lilpug Jul 04 '16 at 11:45
  • 1
    look at this http://stackoverflow.com/questions/30985426/referencing-library-in-asp-net-core-1-0-vnext – Codeone Jul 04 '16 at 11:59
  • that doesn't really help, i don't want to have to create a separate class project library just to add external references into my project – lilpug Jul 04 '16 at 12:16
  • @lilpug "I dont't want"? Seriously you should say "I don't want to code". – Lex Li Jul 04 '16 at 12:35
  • 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 http://stackoverflow.com/questions/38107573/how-to-add-project-reference-to-asp-net-core-1-0-mvc-project – lilpug Jul 04 '16 at 12:42
  • As others have said, packaging a library (.dll) as a NuGet package is obvious the way to go (even the error message says it so). You don't need the source code to build a NuGet package if you simply google how. – Lex Li Jul 04 '16 at 12:43
  • i still don't understand why you would build a NuGet package for every external dll especially if its only going to be used in one project by yourself, it just seems very excessive and i don't think that was the real idea for the implementation, which is why there are bug tickets open, i was just curious if anyone has found a temporary solution which does not include wrapping up the dlls in NuGet packages. – lilpug Jul 04 '16 at 15:01
  • 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. – dalemac Jul 04 '16 at 15:39
  • @dalemac the whole tooling is going to change so I treat every bits truly as Preview and don't bother much what happened. The immature part is from Microsoft, and either you use a workaround, or wait for a better solution from them. Your concern of "clogging up NuGet" is not the reality, as a custom feed can always be used for such scenarios. – Lex Li Jul 04 '16 at 23:56

1 Answers1

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.