visual-studio-2015nuget.net-coremyget

Trouble compiling using a MyGet package in .NET Core project


I've created a couple of MyGet packages that I've pushed to my feed. I've successfully referenced those packages in my project. I can see the packages listed in the NuGet Package Manager and I can see them downloaded in Users[username].nuget\packages. In fact, when I deleted those folders in the packages folder and went back to restore packages in my solution, I saw that the folders were downloaded again. Of course, these references are listed in my project.json file as well.

Up to that point all looks good.

Then I tried to reference a class from one of those packages and Visual Studio can't find it at all. It's just giving me the standard "type or namespace...does not exist" error. Also, I tried to pull up the packages in the object explorer to see if that could view the classes, but it was unable to find the packages listed anywhere whereas it can see all of the other Nuget packages that have been pulled down.

I've even gone to my MyGet feed to download a package and make sure all of the classes and interfaces are listed and, sure enough, they are all there.

So to recap - My project references look fine. The internals of the package look fine. VS is downloading the packages into Users[user].nuget\packages. However, I'm completely unable to use the packages in my code.

I don't know if it makes a difference but this is VS 2015 and I'm using .NET Core.

How can I resolve this?

Solution Explorer showing that the 3 packages can't be expanded for more details.


Solution

  • Please pack .NET Core packages with following script code added in project.json file.

    "scripts": {
    "postcompile": [
      "dotnet pack --no-build --configuration %compile:Configuration%"
      ]
    }
    

    After compile your .NET Core project, it will generate .nupck file in \bin\debug file. Then please upload this package to your NuGet feed and install it on your project.

    If I pack the .NET Core packages with your steps that using nuspec file, I get the same issue with you. The .NET Core project is different with common project, which is manager packages with project.json. So please pack your .NET Core packages with project.josn file.