Nuget Install-Package older version

Oct 19, 2011 at 2:49 PM

Fortunately, this is not critical and more of a hypothetical as I am trying to understand the ability to install older versions of NuGet Packages...

Lets say I have packages A and B...
Package A was released with package versions 4.0 and 4.0.1  (both contain assembly versions 4.0.0.0)...
Package B depends on A (>= 4.0.0.0) and was also released with package versions 4.0 and 4.0.1 (again both contain assembly versions 4.0.0.0).

If I have package A v4.0 installed; I understand I can install v4.0 of Package B by (since 4.0.1 is now released):

PM> Install-Package B -version 4.0

However, looking at the log of what happens, the package manager uninstalls package A v4.0 and upgrades it to 4.0.1 -- and then installs package B @ v 4.0 as requested... 

Why, if a pre-existing package A is installed and meets the version requirements (>= 4.0.0.0 in this case), is package A automatically upgraded when installing an older version of B?

The hypothetical scenario is I have been working with Package A for a while (Package B exists, but I do not need it right now)... In the interim a maintenance release is made to packages A and B...  I now need package B, but due to time constraints, I need to add the older version of B without having to re-test my code that references package A.  Therefore I want to add the older B package and NOT update package A at this time...

Thanks for any explanation (or additional command line arguments I missed) that can be provided...

Coordinator
Oct 19, 2011 at 4:46 PM

In short, we conservatively follow the SemVer semantics that a change in the 3rd version part (X.Y.Z) (what they call a "Patch", but what others call a Revision or Build depending on who you ask) represents a bug fix and is a safe upgrade. See http://blog.davidebbo.com/2011/01/nuget-versioning-part-2-core-algorithm.html for more details.

Note that if your scenario was changed such that 4.0.0 and 4.1.0 were in the feed, we would not upgrade you to 4.1.0. We're going to try and really promote these semantics more strongly to package authors. The basic idea is that consumers *want* that bug fix and it should be absolutely safe to take.

Oct 19, 2011 at 5:11 PM

Note that if you *really* want to keep version 4.0 of A, you can add a version constraint attribute to packages.config before the update. See here (http://docs.nuget.org/docs/release-notes/nuget-1.4#Constraining_Upgrades_To_Allowed_Versions)

Oct 19, 2011 at 5:14 PM

Thanks, my plan is to implement SemVer (read about it for the first time yesterday)...

Shouldn't be an issue like you said, just checking to make sure it was expected behavior and whether it could be overridden...