edymtt
edymtt

Reputation: 1808

How to update packages using Nuget.exe

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.

Upvotes: 6

Views: 4021

Answers (1)

edymtt
edymtt

Reputation: 1808

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.

Upvotes: 6

Related Questions