19

I have set up a private nuget feed using a empty web application and the nuget server package. It is all working, I can retrieve from the feed, and I can publish to the private feed using the Nuget Package Explorer. But I cant publish via the command line - it prompts for credentials. I have set the ApiKey in the web application in the Appsettings, to a simple password, and I have tried adding the ApiKey to the push command. This Prompts me for a username and then a password. I have also tried the SetApiKey command but I get the same behavior. On the build server I am trying the same thing with the same results.

Here is the error messages from the build Log (identifying info x'd out)

nuget pack "C:\Builds\2\OE Phase II\Common\src\WebApi\Web.Http\Bxxxxxxxs.Web.Http.csproj" -IncludeReferencedProjects -Properties Configuration=Release
  nuget SetApiKey Bxxxxxxx1 -Source http://tfs12.xxxxxxxrps.com/Nuget
  nuget push *.nupkg -s http://tfs12.xxxxxxxrps.com/Nuget/
  C:\Builds\2\OE Phase II\Common\bin\xxxxxxx.Web.Http.dll
  1 File(s) copied
  Attempting to build package from 'xxxxxxx.Web.Http.csproj'.
  Packing files from 'C:\Builds\2\OE Phase II\Common\src\WebApi\Web.Http\bin\Release'.
  Using 'xxxxxxxs.Web.Http.nuspec' for metadata.
  Found packages.config. Using packages listed as dependencies
  Successfully created package 'C:\Builds\2\OE Phase II\Common\bin\xxxxxxxs.Web.Http.1.0.0.0.nupkg'.
  The API Key 'xxxxxxx' was saved for 'http://tfs12.xxxxxxxrps.com/Nuget'.
  Pushing Bxxxxxxxrs.Data 1.0.0.0 to 'http://tfs12.xxxxxxxrps.com/Nuget/'...
  Please provide credentials for: http://tfs12.xxxxxxxrps.com/Nuget/
  Object reference not set to an instance of an object.
  UserName: Password: 
David Brabant
  • 41,623
  • 16
  • 83
  • 111
Noel
  • 1,968
  • 3
  • 20
  • 38

6 Answers6

10

Found solution for Windows Server 2012 and Nuget.Server 2.8.5

  • Open IIS manager
  • find your "Nuget.Server" application
  • right click and select "Edit permissions"
  • go to "Security" tab

Add "write" permission for group "Everyone".

proforov
  • 159
  • 1
  • 5
  • I just marked this as an answer as it has fixed my command line to be able to push a package. Weirdly the Package explorer has stopped working, to push to the server and my search for why has lead me back to my original question. So now the command line is fixed but the Package Explorer still does not work.. – Noel Aug 12 '15 at 18:48
  • 1
    If you want to be a little safer, just add Write permissions to Users not Everyone. – Kam Aug 25 '15 at 07:15
  • 6
    I'm on Windows 7 with IIS 7.x. I had to add the "Write" permission to the following local users: IUSR and IIS_IUSRS – Greg Burghardt Nov 16 '15 at 19:37
  • As suggested by @GregBurghardt, you only have to give write permissions to the IUSR and IIS_IUSRS users. – Erik Schierboom Dec 10 '15 at 10:27
  • 1
    You don't have to give write permissions to entire application. You have to do so only in the directory, where packages are stored. – Liero Mar 22 '16 at 13:50
  • I'm using NuGet.Server 2.11.2 and IIS_IUSRS needs modify only in the packages folder, but IUSR needs modify for the whole thing for some reason. – Sacha K Oct 21 '16 at 08:23
1

API key is for uploading/pushing packages. Looks like you have a http proxy enabled and you can set the username and password by calling nuget.exe config command.

Some example:

nuget config -Set HTTP_PROXY=http://*.*.. -Set HTTP_PROXY.USER=domain\user

nuget.config HTTP_PROXY

http://docs.nuget.org/docs/reference/command-line-reference

Dan Liu
  • 812
  • 5
  • 1
  • The prompt is not asking for proxy credentials. It is asking for the repository credentials. – dss539 Feb 02 '15 at 21:59
1

I had this issue too and I knew it worked before, turns out I was using NuGet.exe 2.8.1 upgrading using

NuGet.exe update -self 

took it to 2.8.3 and now works fine.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
John Kattenhorn
  • 839
  • 11
  • 25
  • This was all I needed. I updated from 4.9.4 to 5.4.0, and after updating, my Azure AD authentication box popped up. Before, it just "froze." – Michael Blackburn Feb 18 '20 at 17:53
1

This worked for me: Site > Authentication > enable Windows Authentication (I only had anonymous by default) and push will use your domain account without user input.

npjohns
  • 2,218
  • 1
  • 17
  • 16
0

Also which version of NuGet.Server package did you use? NuGet already released 2.7.2 version of it.

Can you try and see if the null ref exception still reproes? Thanks.

Dan Liu
  • 812
  • 5
  • 1
0

You may find this SO answer helpful, as it covers how to configure credentials on a workstation and/or build server, which is required to push via a command-line to a server that requires authentication (e.g. private feed.)

An API key is not required to publish.

Community
  • 1
  • 1
Shaun Wilson
  • 8,727
  • 3
  • 50
  • 48