2

I have a Nuget package created from a v4.6 class library, is it possible to reference this in a new ASP.NET 5 xproj class library? I tried it and it gave me this error:

NU1001 The depdency Mylibrary >- 1.0.0 could not be resolved

It comes up as a dependency in my project.json like this but can't find it:

 "frameworks": {
"net451": {
  "dependencies": {
    "MyLibrary": "1.0.0"
  }
},
User101
  • 748
  • 2
  • 10
  • 29
  • First of all you should use `"dnx451"` instead of `"net451"`. If you want use the packaged which compiled for .Net 4.6, then you should use `"dnx46"` instead of `"net451"` or `"dnx451"` – Oleg Jan 18 '16 at 13:22
  • It was an old package compiled for .net4.6, I tried dnx46 and dnx451 with the same error :( – User101 Jan 18 '16 at 13:30
  • Probably the reason was **how** you included the project. Do you used Visual Studio or have created `wrap` directory with the corresponding reference manually? Probably "could not be resolved" means in your case that dnx have no idea where to find Mylibrary? – Oleg Jan 18 '16 at 13:57
  • I added it into the project by right clicking on references on the project, Manager Nuget, then selected the Nuget package which is in our local Nuget repo – User101 Jan 18 '16 at 14:14
  • It could be the problem of metadata from the NuGet package. I'd recommend you to add the assembly first of all. Select the project in Solution, right mouse click to open context menu and to choose "Add"/"Reference". Then you can choice between adding Assembly or adding of old Project, which creates Mylibrary. You can for example add Assembly as `"dnx46"` dependency. Select "DNX 4.6" on the left side under "Assembly" and click "Browse...", choose the Mylibrary.dll. Try to build the project now. – Oleg Jan 18 '16 at 14:24
  • If I add it as a dll it adds it okay - just not as a package :( Its currently looking at my appdata users folder for the nuget.config, how do I point this elsewhere? Is there a Nuget configuration in ASP.NET 5 – User101 Jan 18 '16 at 15:32
  • It's the good news! Then you should open `.nuspec` of the `Mylibrary` package and verify that `` contains ``. I recommend you to examine packages from `%USERPROFILE%\.dnx\packages`. Every package have `.nuspec` inside. – Oleg Jan 18 '16 at 15:36
  • %USERPROFILE%\.dnx\packages does not contain MyLibrary but it does have a lot of the other system ones in it. The nuspec file for MyLibrary does not have a dependencies section, will this be a problem? Thanks for the help so far. – User101 Jan 18 '16 at 15:43
  • One more reason of your problem could be wrong `NuGet.config`. I'd recommend you to read [the answer](http://stackoverflow.com/a/34794054/315935) and [another one](http://stackoverflow.com/a/34421286/315935) to understand the NuGet Configuration and the Inheritance of the Configuration. See [the article](http://docs.myget.org/docs/how-to/nuget-configuration-inheritance) too. For troubleshooting of problem of NuGet configurations it would be the best to start with the commend `dnu feeds list` in the project directory. – Oleg Jan 18 '16 at 15:44
  • I mean that %USERPROFILE%\.dnx\packages conatins a lot of **correct** packages which could be used. Every such package have `.nuspec`. You can examine the `.nuspec` in text editor and compare with `MyLibrary.nuspec`. – Oleg Jan 18 '16 at 15:45
  • Thanks for you help thusfar, for some reason now it still won't find the reference on my machine, but does on my colleagues which suggests something is wrong with my setup, I have tried repairing asp.net 5 RC1 to no avail so something specif on my machine. Could be the config lookup as you say. – User101 Jan 18 '16 at 16:26
  • I wrote you that for the troubleshooting you should start command line in the directory where you have `project.json` and type `dnu feeds list`. You will see **all sources** which uses NuGet for finding packages. The local NuGet repository which have `MyLibrary` have to be in the list. – Oleg Jan 18 '16 at 18:14

0 Answers0