Reputation: 51
I'm hosting a private Nuget server built with Nuget.Server package.
The machine is exposing port 8082. The nuget server is available via web browser on http://domain:8082/nuget, publishing works fine.
Now I'm trying to enable VS2017 to consume packages from this nuget server. After adding new package source "http://mydomain:8082/nuget", I'm able to browse my packages, but Install-Package fails. Obviously it ignores the port number when building the download link.
Here's the output:
PM> Install-Package MyPackage
Restoring packages for D:\someproject.csproj...
GET https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json'&semVerLevel=2.0.0
GET https://www.myget.org/F/aspnetvnext/api/v2/FindPackagesById()?id='Newtonsoft.Json'&semVerLevel=2.0.0
GET http://mydomain:8082/nuget/FindPackagesById()?id='Newtonsoft.Json'&semVerLevel=2.0.0
GET https://www.nuget.org/api/v2/FindPackagesById()?id='MyPackage'&semVerLevel=2.0.0
GET https://www.myget.org/F/aspnetvnext/api/v2/FindPackagesById()?id='MyPackage'&semVerLevel=2.0.0
GET http://mydomain:8082/nuget/FindPackagesById()?id='MyPackage'&semVerLevel=2.0.0
OK http://mydomain:8082/nuget/FindPackagesById()?id='Newtonsoft.Json'&semVerLevel=2.0.0 44 мс
OK http://mydomain:8082/nuget/FindPackagesById()?id='MyPackage'&semVerLevel=2.0.0 62 мс
GET http://mydomain/nuget/Packages(Id='MyPackage',Version='1.0.1')/Download
OK https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json'&semVerLevel=2.0.0 431 мс
OK https://www.nuget.org/api/v2/FindPackagesById()?id='MyPackage'&semVerLevel=2.0.0 441 мс
OK https://www.myget.org/F/aspnetvnext/api/v2/FindPackagesById()?id='MyPackage'&semVerLevel=2.0.0 1436 мс
OK https://www.myget.org/F/aspnetvnext/api/v2/FindPackagesById()?id='Newtonsoft.Json'&semVerLevel=2.0.0 1471 мс
Unable to download package "MyPackage.1.0.1" из "http://mydomain/nuget/Packages(Id='MyPackage',Version='1.0.1')/Download".
Error while sending request.
Unable to connect to remote server
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <mydomain's IP here>:80
Is there a way to fix this behavior?
Upvotes: 1
Views: 599
Reputation: 159
Just to add another point, uncomment the element <add key="aspnet:UseHostHeaderForRequestUrl" value="true" />
in the Web.config of your project or IIS. this is useful if you are behind a firewall or your NugetServer runs on different port. for me, this works.
Upvotes: 1
Reputation: 51
The problem was caused by the network infrastructure settings. Port 8082 was forwarded to port 80, and Nuget server was listening on port 80. Since the urls were rewritten, there were no way for Nuget server to know the correct port number, so it responded with download links without custom port number.
Once I've created a port forward without actually changing the port number, i.e. 8083 to 8083 and set Nuget server to listen on 8083, everything works fine.
Upvotes: 1