Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update packages using Nuget.exe

Tags:

nuget

For my little sample projects in .NET (built directly on the command line without employing Visual Studio) I want to use directly Nuget.exe to retrieve the libraries I need, without having to commit them in the source repository.

I've been able to install them using the command

nuget install packages.config -o $destinationFolder

specifying the needed packages in a packages.config (like Nuget in Visual Studio). However, I'm unable to update installed packages. I've tried to use this command

nuget update packages.config -r $destinationFolder

but Nuget.exe complains that is

unable to locate project file for '...packages.config'`.

I've searched on the Internet but I only find a similar question in the Nuget discussion forums without answers.

like image 789
edymtt Avatar asked Apr 03 '13 18:04

edymtt


People also ask

How do I update Visual Studio packages?

In Visual Studio, the Package Manager Console provides many flexible options for updating and reinstalling packages. On the Installed tab, select a package, record its name, then select Uninstall. Switch to the Browse tab, search for the package name, select it, then select Install).

What does NuGet EXE do?

The NuGet ( nuget.exe ) CLI, provides the full extent of NuGet functionality to install, create, publish, and manage packages without making any changes to project files.


1 Answers

I've read the relevant source files in the Nuget project and I've discovered that for the update to succeed Nuget.exe needs to find a Visual C#/Basic/F# project.

I then created an empty csproj file in the folder and I've been able to update the packages I've installed before.

I've made a small sample at https://github.com/edymtt/nugetstandalone that shows how to install and update packages with Nuget.exe. I've also used a workaround to make sure that only the latest versions of the libraries are kept in the folder.

Update 2013-04-06 14:20 UTC I've updated the sample to show how to achieve that using the -ExcludeVersion flag of the install command.

like image 59
edymtt Avatar answered Oct 12 '22 10:10

edymtt