简体   繁体   中英

How configure packages.config to download the highest version

I want to configure packages.config to download the available highest version of a package. How can I do that?

Something like:

<package id="PackageName" version="Highest" ... />

I saw attr "allowedVersions", but it always download the version configured in "version" attr.

How configure packages.config to download the highest version

Just as Ashley and Matt said, it is impossible to do that, because packages.config only allows a single version of a package to be specified.

The simple workaround is using nuget cli to update that package in the pre-build event:

$(YourNuGetPath)\nuget.exe update "$(ProjectDir)packages.config" -Id "<YourPackageId>"

With this build event, Visual Studio will update that package to the latest version before you build your project.

Unfortunately, this isn't possible with NuGet it only allows specific versions. The allowedVersions is used to block someone from going beyond or below a specific version. ie version 1.* is fine but you cannot go to version 2.0.

A typical workaround for something like this is a batch/powershells script which updates the package you want. You could then hook this into a pre-build.

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