Package Restore results in error 400 Bad Request

Topics: General
Sep 26, 2012 at 5:20 AM
Edited Sep 26, 2012 at 5:30 AM

One machine in our group is having trouble with package restore. When a clean checkout is performed (without packages checked into source control), and we try to build on this machine (either in VS 2010 or VS 2012), the call to nuget.exe to restore the packages for the solution results in an error 400 Bad Request.

Further inspecting the output window, I've found that nuget.exe is being called with the following parameter and value

-source ""

The empty string seems to be causing the problem.  Here is the full failed command as written to the output window:

D:\Projects\MyProject\.nuget\nuget.targets(80,9): error : The remote server returned an error: (400) Bad Request.

D:\Projects\MyProject\.nuget\nuget.targets(80,9): error : One or more errors occurred.

D:\Projects\MyProject\.nuget\nuget.targets(80,9): error MSB3073: The command ""D:\Projects\MyProject\.nuget\nuget.exe" install "D:\Projects\MyProject\Tests\packages.config" -source ""  -RequireConsent -o "D:\Projects\MyProject\packages"" exited with code 1.

On this machine, I have verified that I can create a new console app and successfully nuget in a package such as log4net.  However, once I enable package restore on the solution, I start getting the 400 Bad Request error

If I try nuget.exe with the -source "" parameter and value from the command line, the error returned is

Invalid URI: The format of the URI could not be determined.

So we know that

  1. The error is not related to the solution. The problem can be replicated on a new project
  2. The error only occurs when package restore is enabled
  3. The -source parameter is passed with an empty string value ""
  4. Installing a new package using the package manager work successfully
  5. This is the only machine where the error is occuring
  6. We have verified that the package source is correct: "NuGet official package source" = https://nuget.org/api/v2/

Any help would be greatly appreciated.

Thanks,

Jeff Schumacher

Developer
Sep 26, 2012 at 4:09 PM

By commandline, do you mean powershell? If so, you might need to escape those double quotes (.\nuget.exe install -Source `"`" packages.config). Could you list out the configured sources that the exe reads (.\nuget.exe sources)

Sep 26, 2012 at 5:37 PM
pranavkm wrote:

By commandline, do you mean powershell? If so, you might need to escape those double quotes (.\nuget.exe install -Source `"`" packages.config). Could you list out the configured sources that the exe reads (.\nuget.exe sources)

Thanks for the response pranavkm, you're correct, the double quotes have be escaped in PowerShell. However that only affects my test.

Fortunately it looks like this issue was completely related to our proxy server. After resetting the proxy server settings on the machine, the issue has gone away.