Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 901
satellite satellite Avatar asked Mar 19 '18 15:03

satellite satellite


People also ask

How do I change NuGet package version?

Right-click the Packages folder in the project, and select Update. This will update the NuGet package to the latest version. You can double-click the Add packages and choose the specific version.

How do I run package config?

If you right click the project in question you can select "Manage nuGet Packages" from the menu. After you do that you can click "installed packages" on the left hand side to see the packages that you currently have installed. These are what you are seeing in your "packages. config" file.

What is package config Targetframework?

packages. config: The targetframework attribute of a dependency specifies the variant of a package to install.

What is the use of packages config?

The packages. config file is used in some project types to maintain the list of packages referenced by the project. This allows NuGet to easily restore the project's dependencies when the project is to be transported to a different machine, such as a build server, without all those packages. If used, packages.


1 Answers

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.

like image 67
Leo Liu-MSFT Avatar answered Sep 26 '22 15:09

Leo Liu-MSFT