Download old version of package with NuGet
Asked Answered
I

8

927

Is there a way to download a previous version of a package with NuGet, not the latest one?

Internationale answered 11/4, 2011 at 23:18 Comment(0)
P
1131

Bring up the Package Manager Console in Visual Studio - it's in Tools / NuGet Package Manager / Package Manager Console. Then run the Install-Package command:

Install-Package Common.Logging -Version 1.2.0

See the command reference for details.

Edit: In order to list versions of a package you can use the Get-Package command with the remote argument and a filter:

Get-Package -ListAvailable -Filter Common.Logging -AllVersions

By pressing tab after the version option in the Install-Package command, you get a list of the latest available versions.

Piracy answered 12/4, 2011 at 12:50 Comment(9)
Explicitly getting a list of available packages: follow @Maciek 's response. You should also notice that when typing a space after the -Version argument, the NuGet Console in VS will show you some autocomplete list with the available versions for that package.Finalize
For the benefit of those who have been using Nuget for a while but never done anything with it from the command line: To run the powershell commands that PHeiberg mentions you will want to bring up the Package Manager Console in Visual Studio - it's in Tools|Library Package Manager|Package Manager Console.Summertime
OR View | Other Windows | Package Manager Console =]Cirone
This command should also be available via the UI. Now if a publisher has a beta version, you can only get that latest version, which is sometimes unstable.Knapsack
@bgever - Most publishers create Prereleases for beta packages which are not considered the "Latest" in the GUI. As long as the publisher uses versioning correctly, the latest version should always be a stable one. That doesn't mean it won't have bugs however...Launcelot
Dependency info and examining what other properties are available: Get-Package -ListAvailable [-Source X] -Filter Common.Logging -AllVersions | select version, dependencies (or '| get-member' to see all the properties)Acrodont
Get-Package -ListAvailable does not list all available versions for me.Orlon
The ListAvailable argument in the Get-Package command has been deprecated. You should use Find-Package <id> -AllVersions insteadSterne
@makhdumi : For big projects I only install packages from a local packages mirror. To add a package I open a small visual studio project and only install it there first . From the small project I copy the package to the local packages mirror and then update it in the bigger project.Roxyroy
C
54

Browse to its page in the package index, eg. http://www.nuget.org/packages/Newtonsoft.Json/4.0.5

Then follow the install instructions given:

Install-Package Newtonsoft.Json -Version 4.0.5

Alternatively to download the .nupkg file, follow the 'Download' link eg. https://www.nuget.org/api/v2/package/Newtonsoft.Json/4.0.5

Obsolete: install my Chrome extension Nutake which inserts a download link.

Chanteuse answered 7/3, 2013 at 20:17 Comment(0)
D
37

Another option is to change the version number in the packages.config file. This will cause NuGet to download the dlls for that version the next time you build.

Divergent answered 17/4, 2014 at 20:46 Comment(2)
Nice one... didn't think about that. I guess NuGet Package Restore has to be enabled for the solution though.Cirone
This isn't enough to also change the assembly reference automagically. What works though (if you have at lease two assemblies in your solution) is this: 1. make sure one assembly references the package, 2. edit the correct version in packages.config, 3. manage the NuGet packages on the solution, 3a. add the package to another project, removing it from the original project, and confirm this, 3b. reverse 3a and confirm. Step 3a will add the correct assembly reference to another project and remove it from the original. Step 3b will add the correct assembly reference to the original project.Shericesheridan
P
26

In NuGet 3.x (Visual Studio 2015) you can just select the version from the UI

NuGet 3 package manager UI

Portecochere answered 20/10, 2015 at 20:6 Comment(1)
Nice when it works but I've seen cases where not all old versions are listed there.Daw
J
7

In NuGet 3.0 the Get-Package command is deprecated and replaced with Find-Package command.

Find-Package Common.Logging -AllVersions

See the NuGet command reference docs for details.

This is the message shown if you try to use Get-Package in Visual Studio 2015.

This Command/Parameter combination has been deprecated and will be removed
in the next release. Please consider using the new command that replaces it: 
'Find-Package [-Id] -AllVersions'

Or as @Yishai said, you can use the version number dropdown in the NuGet screen in Visual Studio.

Jacquerie answered 25/2, 2016 at 22:53 Comment(0)
T
4

As the original question does not state which NuGet frontend should be used, I would like to mention that NuGet 3.5 adds support for updating to a specific version via the command line client (which works for downgrades, too):

NuGet.exe update Common.Logging -Version 1.2.0
Trinhtrini answered 12/7, 2016 at 14:27 Comment(0)
D
2

I landed on this page but my requirement is different, I wanted to download old version of .nupkg file instead of downloading from VS2019 - to get old version of .nupkg

  1. Go to nuget.org
  2. Search package ex: Newton Json
  3. Click on result package name
  4. Click on Versions tab and download the version you want
  5. screenshot
Dogcatcher answered 19/10, 2021 at 21:28 Comment(0)
B
0

By using the Nuget Package Manager UI as mentioned above it helps to uninstall the nuget package first. I always have problems when going back on a nuget package version if I don't uninstall first. Some references are not cleaned properly. So I suggest the following workflow when installing an old nuget package through the Nuget Package Manager:

  1. Selected your nuget server / source
  2. Find and select the nuget package your want to install an older version
  3. Uninstall current version
  4. Click on the install drop-down > Select older version > Click Install

enter image description here

Good Luck :)

Beeeater answered 21/4, 2020 at 14:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.