Search code examples
visual-studioproxynugetnuget-packagehttp-proxy

(405) Method Not Allowed with Visual Studio 2017 (NuGet) Package Manager


The Error that I get in the Visual Studio Package Manager Output is:

[nuget.org] Unable to load the service index for source https://www.nuget.org/api/v2.
  An error occurred while sending the request.
  The remote server returned an error: (405) Method Not Allowed.

Configuring a proxy in NuGet.config or not configuring a proxy had no effect on the result.

nuget.org in my config is:

<add key="nuget.org" value="https://www.nuget.org/api/v2" />

If I set the environments http_proxy to my companies proxy I can reproduce this using nuget.exe (NuGet Version: 4.7.0.5148)

nuget list -source nuget.org -ForceEnglishOutput

Unable to load the service index for source https://www.nuget.org/api/v2.
  An error occurred while sending the request.
  The remote server returned an error: (405) Method Not Allowed.

If I clear the environment http_proxy the same command starts listing packages. (which I abort using crtl+c).

I know that there is a difference between the package manager in visual studio and nuget.exe.

As I understand both use the same nuget.config file. As I see it somehow the package manager uses a proxy setting that I did not check. I can not find where that would be.

Is there a proxy setting that I did not check? Am I missing something else?

EDIT: When I remove the proxy Settings from Nuget.Config and then update a package source in visual studio my Nuget.Config Settings are rewritten which restores my proxy settings.


Solution

  • Visual Studio kept a copy of the config in memory. Every time the package manager connects it rewrites nuget.config.

    So my issue was solved by closing vs2017, editing the nuget.config by hand and restarting visual studio.