Search code examples
paket

In a paket.dependencies file, what is the meaning of the operator `==`?


In a project's paket.dependencies file, I found thoses lines:

nuget Microsoft.AspNet.Mvc == 5.2.6
nuget Microsoft.AspNet.Razor == 3.2.6
nuget Microsoft.AspNet.WebPages == 3.2.6

I checked the official documentation without success. My guess would be that == could fix a version number but to achieve this we can directly write nuget Microsoft.AspNet.Mvc 5.2.6.

What is the meaning of the operator ==?


Solution

  • It's called the "Use exactly this version" constraint. It really should be part of the paket.dependencies reference but instead it is found in: https://fsprojects.github.io/Paket/nuget-dependencies.html

    I'll try to explain it with an example. Imagine that you depend on packages A & B.

    Both A and B depend on C but in their respective nuget package dependency declaration they specify that:

    A depend on C version >= 1.2.3 but < 2.0

    B depend on C version >= 2.0

    In this situation paket will fail to find a common version of C that suits both A and B.

    I've seen cases in some projects where there is a dependency to a package like A that claims it won't work with versions >= 2.0 of package C. However when actually tested, A works just fine with the highest version of C. Therefore a line to force paket to override the version constraint A have on C can be added:

    nuget C == 2.0
    

    Of course, the long term solution is to ask the maintainer of A to update their nuget dependency declaration.