Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to automatically update nuget.exe in the .nuget folder when using package restore?

Tags:

nuget

My team has been using the Enable Package Restore option since Nuget 1.5 to keep packages out of our source control. When Nuget 1.6 was released we noticed an issue where it wasn't pulling the packages down, and tracked it down to the Nuget.exe in the .nuget folder needed to updated to 1.6 to match the Package Manager.

What's the best way to update a solution once Nuget has been udpated? I don't see an easy way from studio to tell which version of nuget is in the solution folder. So far we blow away the .nuget folder and re-run the Enable Package Restore command.

like image 480
Rick Avatar asked Apr 11 '12 18:04

Rick


People also ask

What is the .NuGet folder?

nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed. Worst case, it will have to download the packages again in the future. Follow this answer to receive notifications.


2 Answers

I would suggest updating .nuget\nuget.exe with this command from the command line:

nuget.exe update -self 

[EDIT] : Close VS Solution first. If there's an update and the solution is opened, nuget.exe will be removed from the solution.

You could automatically update nuget.exe on restore by modifying the .nuget\nuget.targets to add the above command. I'd look at the restore command in there as an example. But I'm not sure if it's worth it, nuget.exe updates aren't that common, and backward compatibility should break very rarely.

like image 102
Alexandre Dion Avatar answered Sep 28 '22 03:09

Alexandre Dion


I've found the best way to handle this is by simply deleting the .nuget folder and re-enabling solution wide package restore. As said above, you could add a self update command to your build, but that will not update the targets or config files if there are changes between versions (or remove the reference from your solution). Perhaps its not that big of a deal, but this is the sure fire way to make sure you have the latest exe and configuration files. And at the end of the day, updating is only an issue if you need access to a new command or there is eventually a breaking change in a new release.

like image 38
Chris Kirby Avatar answered Sep 28 '22 04:09

Chris Kirby