简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM