We have an internal Nuget Server we use to manage our software packages. As part of our upgrade to TFS2012 this needed to be moved to a new server VM and I took the chance to upgrade it from 1.7 to 2.1.
Now we had had a problem that we could publish to the server via a file copy to its underlying Packages folder (a UNC share) but could never publish using the Nuget command e.g.
Nuget push mypackage.nupkg -s http://mynugetserver
I had never had the time to get around to sorting this out until now.
The reported error if I used the URL above was
Failed to process request. 'Access denied for package 'Mypackage.'.
The remote server returned an error: (403) Forbidden..
If I changed the URL to
Nuget push mypackage.nupkg -s http://mynugetserver/nuget
The error became
Failed to process request. 'Request Entity Too Large'.
The remote server returned an error: (413) Request Entity Too Large..
Important: This second error was a red herring, you don't need the /nuget on the end of the URL
The solution was actually simple, and in the documentation though it took me a while to find.
I had not specificed an APIKey in the web.config on my server, obvious really my access was blocked as I did not have the shared key. The 413 errors just caused me to waste loads of time looking at WCF packet sizes because I had convinced myself I needed to use the same URL as you enter in Visual Studio > Tools > Option > Package Management > Add Source, which you don't
Once I had edited my web.config file to add the key (or I could have switched off the requirement as an alternative solution)
Determines if an Api Key is required to push\delete packages from the server.
<add key="requireApiKey" value="true" />
Set the value here to allow people to push/delete packages from the server.
NOTE: This is a shared key (password) for all users.
<add key="apiKey" value="myapikey" />
Change the path to the packages folder. Default is ~/Packages.
This can be a virtual or physical path.
<add key="packagesPath" value="" />
I could then publish using
Nuget mypackage.nupkg myapikey -s http://mynugetserver