15

When build my solution, I got an error:

Error 116 The command "nuget install “C:\Mycode\Test\some\ClassLibs\WCF\ServiceHosts\Monitor\packages.config” -o “C:\Mycode\Test\Some\ClassLibs\WCF\ServiceHosts\Monitor\packages.config”" exited with code 9009

I use VS 2012, Thanks.

2 Answers2

23

To resolve the 'nuget exited with code 9009' error, I downloaded the newest version of NuGet.exe (https://www.nuget.org/downloads) and placed it in the C:\Windows directory so Windows could find the executable.

halfer
  • 19,824
  • 17
  • 99
  • 186
Nick Hotalling
  • 261
  • 2
  • 7
  • 1
    In my case, nuget.exe already existed in C:\Windows\system32 but not in C:\Windows Copying it up one folder worked for me. – Phred Menyhert May 25 '18 at 21:36
  • 1
    If you decide to use another folder, add it to the PATH env var, and *restart* VS. Make sure you can see nuget.exe from your command line – Jose Parra Sep 27 '18 at 04:17
16

Error 9009 means that Visual Studio cannot find an executable - typically one used in a pre or post build step. In this instance, it seems that NuGet is the source of the problem.

Is it possible that you are using a solution that manages dependencies using NuGet (and probably has the "Enable NuGet package restore" option enabled), but you haven't yet loaded the NuGet extension into Visual Studio 2012?

To confirm if this is the case, go to the Tools menu, and click "Extensions and Updates", select installed and type nuget Return into the search box at the top right corner of the Extensions and Updates form. If it's installed, you should see it listed with a version number - for example 2.4.40116.9051 which I believe is the most recent release as I type this. If you don't find it, select "online" from the list on the left hand side of the Extensions and Updates form. Locate the NuGet Package Manager entry (quite possibly the first item on the list) and click "download" to grab it.

Richard J Foster
  • 4,278
  • 2
  • 32
  • 41
  • 1
    I do have NuGet in Visual Studio 2012. I thought that I should modify the project file but not sure. –  Feb 26 '13 at 20:10
  • Possibly. The error doesn't look quite kosher because I believe the parameter after the -o should be a directory, and it appears to be a file. Do you get more/better information if you execute the install command directly from the package manager console? – Richard J Foster Feb 26 '13 at 20:22
  • I tried it in package manager console, then the error disappeared. Why? The version of nuget is 2.2.40116.9051. –  Mar 13 '13 at 15:30
  • Your guess is as good as mine, I'm afraid. :-( The only thing I can think of is that the Error 9009 was getting triggered as a result of NuGet returning an error status when it tried to restore the packages. I wonder if perhaps the "package restore" operation had been prepared for an earlier version of NuGet and the command line parameters were incompatible. I suspect that when you used the package manager console, NuGet realized "Hey, I don't have package xyz!" (as it should have during the build) and grabbed it. Now all the dependency packages are available, all is well. – Richard J Foster Mar 13 '13 at 18:21
  • The simple fix of typing "dotnet restore" in the Package Manager Console before using nuget seems to do the trick for me! – Phillip Feb 07 '20 at 22:29