Search code examples
visual-studionugetnuget-packagenuget-server

How are NuGet repos organized?


I decided to push a .NET Standard class library to an existing local NuGet repo at my workplace.

I did it by having the NuGet package automatically pushed after the build in Visual Studio:

nuget push [PACKAGE_FILENAME] -Source [REPO_ON_THE_NETWORK]

Prior to my push, there were 3 pre-existing packages for other projects in the repo. After my push, the only project visible - via the NuGet Package Manager UI in Visual Studio - was the one I just pushed. I can consume my project from the NuGet repo without issues.

I took a look in the folder itself on the network, and this is what I saw:

[ ] Repo
 |
 |_ [ ] Proj1
 |   |
 |   |_ [ ] v1.0.0
 |   |   |
 |   |   |_ [ ] lib
 |   |   |   |
 |   |   |   |_ [ ] net20
 |   |   |   |   |
 |   |   |   |   |_ .dll
 |   |   |   |   |_ .pdb
 |   |   |   |
 |   |   |   |_ [ ] net46
 |   |   |       |
 |   |   |       |_ .dll
 |   |   |       |_ .pdb
 |   |   |
 |   |   |_ .nupkg
 |   |   |_ .nupkg.sha512
 |   |   |_ .nuspec
 |   |
 |   |_ [ ] v1.0.1
 |       |
 |       |_ .nupkg
 |       |_ .nupkg.sha512
 |       |_ .nuspec
 |
 |_ [ ] MyRecentlyPushedProj
   |
   |_ .nupkg

I have three questions:

  • Why are the folder's organized in such different ways? Notice how one folder has a sub-folder with the actual project binaries, while the others don't. Also notice how my recently-pushed project lacks everything except for the NuGet package file.
  • When we manually delete the recently-pushed project from the repo, then the old projects reappear in the NuGet Package Manager UI. Does having differently-organized folders mess with NuGet's ability to scan the repo? Has the way NuGet organizes the projects changed over time (with newer versions)?
  • How am I able to consume the recently-pushed project successfully without the folder containing any of the binaries?

Solution

  • From the hierarchy tree you drew, I can see some differences:

    1. Your package doesn't come with a version.
    2. Your package doesn't have a lib folder.

    Now, there are two ways of publishing a NuGet package with NuGet CLI: push and add. The main difference is that add is for non-HTTP package source (as stated on MSDN) and that it publishes the package in a hierarchic manner, while push doesn't always (and it usually depends on how the feed was initialized).

    My recommendation is that you check the documentation I added, and based on that decide whether to use one command or the other. From what I can gather, you should use add.

    Hope this helps.