Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet exited with code -1 — Build failing as a result

I have installed dotless via Package Manager in VS2012 in to an existing mixed C# solution (Class libraries and MVC2 apps), however now when I build it (F5) I get the following two errors:

The command ""C:\@GitRepos\EBS\SolutionFiles\.nuget\nuget.exe" install "C:\@GitRepos\EBS\\packages.config" -source "" -o "C:\@GitRepos\EBS\SolutionFiles\packages"" exited with code -1.

and

The system cannot find the path specified.

After adding dotless to the solution a ".nuget" folder with "NuGet.exe and "NuGet.targets" has been added.

I have also tried adding dotless to a new MVC2 project and other than having to add a mime type to the web.config it all works well. There isn't however a ".nuget" folder.

I also noticed that the same happens if I create a new NServiceBus solution (after installing it). The paths in the message change but the error is the same.

If I take

"C:\@GitRepos\EBS\SolutionFiles\.nuget\nuget.exe" install "C:\@GitRepos\EBS\\packages.config" -source "" -o "C:\@GitRepos\EBS\SolutionFiles\packages"

and run it via a command prompt then I get:

All packages listed in packages.config are already installed.

like image 447
Canters Avatar asked Jun 20 '12 08:06

Canters


People also ask

How do I fix NuGet recovery failed?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

How do I force a NuGet restore?

Restore by using MSBuild You can use msbuild -t:restore to restore packages in NuGet 4. x+ and MSBuild 15.1+, which are included with Visual Studio 2017 and higher. This command restores packages in projects that use PackageReference for package references.

How do I restore NuGet in Visual Studio?

In Tools -> Options -> NuGet Package Manager -> General you need to select the "Allow NuGet to download missing packages" option which allows NuGet to restore and the "Automatically check for missing packages during build in Visual Studio" which enables on build restore.

How do I get NuGet packages in Visual Studio 2022?

Set up Visual StudioIn Visual Studio, select Tools, and then select Options. Select NuGet Package Manager, and then select Package Sources. Enter the feed's Name and Source URL, and then select the green (+) sign to add a new package source.


3 Answers

So after giving up on this and then a few days later looking in to it again, I found the answer. I came across david-martos.blogspot.co.uk. After opening my command prompt and finding it also said "The system cannot find the path specified" I went looking in the registry. I found in "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" that there was an AutoRun key for "c:\ansi140\x64\ansicon.exe -p ". After deleting this and trying one of my NserviceBus solutions again I found it built fine. I hope this helps others.

Here is a direct link to David Martos post.

like image 164
Nathan McKenzie Avatar answered Oct 18 '22 14:10

Nathan McKenzie


This was also likely a nuget package restore consent that you had to set. http://blog.nuget.org/20120518/package-restore-and-consent.html

For anyone who wants to permanently have the consent accepted, take a look at installing http://nuget.org/packages/NuGetEnablePackageRestore - it will be accepted on all machines automatically.

like image 23
ferventcoder Avatar answered Oct 18 '22 13:10

ferventcoder


I solved this problem by opening up the Package Manager Console and clicking on the "Restore" button on the warning that popped up. Here's a pick of what it looked like. This is similar to the other solutions, but from a different angle.

enter image description here

like image 36
mkimmet Avatar answered Oct 18 '22 14:10

mkimmet