Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Package restore exited with code -1

I get the following error in the Ouput window:

D:\{solutionPath}\.nuget\nuget.targets(76,9): error : 
D:\{solutionPath}\.nuget\nuget.targets(76,9): error : Unhandled Exception: OutOfMemoryException.
D:\{solutionPath}\.nuget\nuget.targets(76,9): error MSB3073: The command ""D:\{solutionPath}\.nuget\nuget.exe" install "D:\{pathToConfigLocation}\packages.config" -source "" -o "D:\{solutionPath}\packages"" exited with code -1.

The above is with the NuGet.targets as it comes.

D:\{solutionPath}\.nuget\nuget.targets(76,9): error : 
D:\{solutionPath}\.nuget\nuget.targets(76,9): error : Unhandled Exception: OutOfMemoryException.
D:\{solutionPath}\.nuget\nuget.targets(76,9): error MSB3073: The command ""D:\{solutionPath}\.nuget\nuget.exe" install "D:\{pathToConfigLocation}\packages.config" -source "{localPackageDir}" -o "D:\{solutionPath}\packages"" exited with code -1.

Is with my package source in the NuGet.targets

When the build is taking place it creates as many nuget.exe processes as it takes for it to use up all the memory, then it fails and has another go at it.

I have taken the command and run it via cmd.

"D:\{longPah}\.nuget\nuget.exe" install "D:\{longPah}\packages.config" -source "\\{longPah}\NuGetPackages" -o "D:\{longPah}\packages"

This gives me the following error:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembl
y 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
 one of its dependencies. Exception from HRESULT: 0x800705AF
   at Bootstrapper.Program.Main(String[] args)

I have .net 4 on the machine.

Please help if you can.

Thanks, David

EDIT

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Company.Common.Library" version="0.1.2" targetFramework="net35" />
</packages>

packages.config as requested.

EDIT

I have tried running the command via Visual studio command prompt (running as administrator) and it throws the following exception:

Unhandled Exception: OutOfMemoryException.

EDIT - POSSIBLE FIX

I think I have found the problem... its seems to be to do with the nuget.exe thats inside the .nuget folder.

I have several solutions and found a couple that work, waisted loads of time looking at file perms (was advised that was the issue) then thought to check the nuget.exe properties in each of the solutions.

In the solutions that worked I found:

enter image description here

In the solutions that wouldn't I found:

enter image description here

As you can see, the file size of the two is drastically different. All the projects got added by different people in the team, Could this be an issue with the version of nuget installed on the dev's machines?

If so does anyone know which version of nuget causes the above issue when you select to enable package restore for the solution? I have the latest version of NuGet installed on my machine btw.

like image 746
David McLean Avatar asked Jul 03 '12 16:07

David McLean


People also ask

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

What is the difference between NuGet restore and dotnet restore?

nuget restore will ensure all of your NuGet dependencies are downloaded and available to your project. Whereas dotnet restore is a complete restoration of all NuGet dependencies as well as references and project specific tools. Meaning that if you run nuget restore , you are only restoring NuGet packages.

How do you delete and restore a NuGet package?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

Does dotnet restore use NuGet?

The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. In most cases, you don't need to explicitly use the dotnet restore command, since a NuGet restore is run implicitly if necessary when you run the following commands: dotnet new.


1 Answers

Both of them will cause the error. The smaller file is just a shell that passes commands to a real version that it downloads to %LOCALAPPDATA%\NuGet. It checks for newer versions every 10 days.

Take a look at this issue: http://nuget.codeplex.com/workitem/2390 (nuget package restore assumes internet access) - could be that the 18K shell is trying to download the full nuget.exe to the %LOCALAPPDATA%\NuGet folder and can't for some reason.

When NuGet 2.0 was released it came with an opt-in consent for Package Restore. Take a look at http://blog.nuget.org/20120619/nuget-2.0-released.html and http://blog.nuget.org/20120518/package-restore-and-consent.html, which details what needs to be done to get it to work.

Alternatively you can permanently accept the entire consent by using the NugetEnablePackageRestore package - http://nuget.org/packages/NuGetEnablePackageRestore - note that this fix will fix it for all future users including build servers.

like image 56
ferventcoder Avatar answered Sep 22 '22 12:09

ferventcoder