0

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.

lostdeveloper
  • 73
  • 1
  • 6
  • how did you create those packages? `dotnet pack` on another project.json or nuspec + csproj? – Martin Ullrich Oct 31 '16 at 21:21
  • I added a nuspec. It's an xproj since it's .NET core. – lostdeveloper Oct 31 '16 at 21:27
  • hmm.. if you use .net core tooling for the nuget package also, you don't need a nuspec, only project.json and then do `dotnet pack -c Release` and it should put a `.nupkg` somewhere in your `bin` folder. the correct package layout for multi-targeting packages is a bit complex so `dotnet pack` is your best friend for .net core.. – Martin Ullrich Oct 31 '16 at 21:32
  • The `packOptions` portion of `project.json` lets you specify all the additional properties you had to add to a nuspec if you were using a csproj. – Martin Ullrich Oct 31 '16 at 21:35
  • @MilanMalkani Does your library show up if you expand References in the Solution Explorer? – Nate Barbettini Oct 31 '16 at 22:07
  • Yes, it's in the references in solution explorer. It's like the solution and project see the reference but can't see anything inside of it. – lostdeveloper Nov 01 '16 at 01:27
  • @martin ullrich, I'll look into the dotnet pack command to learn more about it. – lostdeveloper Nov 01 '16 at 01:28
  • One thing that is strange in solution explorer is that the MyGet references don't have the arrow to expand next to them while all of the other references do. There is no error or warning icon on the references. – lostdeveloper Nov 01 '16 at 01:37
  • I've added a screenshot of solution explorer. – lostdeveloper Nov 01 '16 at 04:55

1 Answers1

1

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.

Weiwei
  • 3,674
  • 1
  • 10
  • 13
  • Thank you for the help! This set me on the right path and solved the problem. However, I did take a slightly different approach for getting the package into MyGet. I took Wendy's advice and added the line to the configuration. Once that was done, I still used the MyGet Build Services to pull the code directly from GitHub and build and deploy my packages instead of uploading the package manually. Thank you again for helping me solve this. – lostdeveloper Nov 02 '16 at 05:34