NuGet / NuGetGallery

NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
https://www.nuget.org/
Apache License 2.0
1.55k stars 644 forks source link

Update the instructions on how to self host the NuGet Gallery #7172

Open rekna1 opened 5 years ago

rekna1 commented 5 years ago

We are hosting a private nuget gallery in our company which was an older version.

I have upgraded this older version of the nuget gallery to the latest release version v2019.01.14. I was able to build, update the database, run the gallerytool succesfully and the website seems to run as as expected. I can see all packages

I then pushed a nuget package using the nuget.exe version 4.9.4.5839 succesfully to my nuget gallery using the command :

NuGet.exe push XXX.YYY.1.1.0.3.nupkg -apikey xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -Source http://nugetgallery2.mydomain.mycompany.be (real names changed for obvious reasons)

I than try to install the package in another project using the package manager console :

Install-Package XXX.YYY -Version 1.1.0.3 -Source http://nugetgallery2.mydomain.mycompany.be/api/v2/package/

which returns an error : Install-Package : An error occurred while retrieving package metadata for 'XXX.YYY.1.1.0.3' from source 'http://nugetgallery2.mydomain.mycompany.be/api/v2/package/'. Failed to fetch results from V2 feed at 'http://nugetgallery2.mydomain.mycompany.be/api/v2/package/Packages(Id='XXX.YYY',Version='1.1.0.3')' with following message : Response status code does not indicate success: 400 (The format of the package id is invalid). Apparently the regex IdRegex in the PackageIdValidator return false on the IsMatch The packageId parameter of IsValidPackageId = Packages(Id='XXX.YYY',Version='1.1.0.3')

Any idea why this is happening ?

joelverhagen commented 5 years ago

The V2 source URL for NuGetGallery ends with /api/v2 not /api/v2/package. So for your Install-Package command, use the following source:

http://nugetgallery2.mydomain.mycompany.be/api/v2

If that ends up working for you, could you tell me the reason you though the source URL was the value you provided? I agree it's confusing and hard to discover what the right value is but I am very curious about exactly what got you started with that incorrect value? If we can identify that we can help other users avoid this confusion, perhaps.

Coincidentally, I recently got bothered enough about this problem on nuget.org itself and filed this issue: https://github.com/NuGet/NuGetGallery/issues/7168. I've known about this inconsistency for ages but just a couple days ago I took the time to actually look at our telemetry to see how much it was affecting users. This data of course represents only nuget.org traffic but I think it's the same root cause as what you are running into.

rekna1 commented 5 years ago

Apparently that solved the issue for me. I can't remember exactly how I got to this incorrect url, I tried so many variations (unfortunately not the correct one). The instructions for setting up a nuget gallery (or upgrading an existing in my case) are not so clear. I think the instructions for a new gallery are a bit outdated and instructions for upgrading not existing or hard to find at least. The issues I encountered (which may be of help for others) are :

It would be helpfull if all information would be available on one single page with up to date info. Did you ever consider creating a docker container for hosting a private nuget gallery, that would probably simply installation and upgrading a lot !

loic-sharma commented 5 years ago

Thank you for all that information, this is great feedback! I've updated this issue's title to track this work

cmatthew206 commented 5 years ago

Does anyone have resources for deploying the gallery with Windows Docker Containers?

skofman1 commented 5 years ago

@cmatthew206 , we never deployed the Gallery to Windows Docker Containers, so can't make any recommendations. If you do try, let us know how it went. We would love to add this to our instructions.