3

Introduction

According to this documentation it is possible to specify dependencies including versions per package as follows:

<dependencies>
    <dependency id="Chocolatey" version="0.9.8.20" />
</dependencies>

Question

Which Nuspec snippet needs to be applied in order to install dependencies' latest version?

030
  • 10,842
  • 12
  • 78
  • 123

3 Answers3

3

Unfortunately there is nothing you can do in the .nuspec file itself. Your options are:

  • Use NuGet v2.7.2 and earlier (Gary's answer)
  • Use -DependencyVersion Highest with NuGet.exe invocations
  • Add the dependency version config setting to the NuGet.config file (not the nuspec file as Chris suggested)

    <config>
    <add key="dependencyversion" value="Highest" />
    </config>
    
Tim
  • 333
  • 3
  • 7
2

You should be able to leave the version empty, which will pull the latest version.

This is documented on the nuget site here:

http://docs.nuget.org/docs/reference/versioning#Specifying_Version_Ranges_in_.nuspec_Files

NOTE: This approach is only valid on NuGet Version's of 2.7.2 and earlier. If you are using an newer version of NuGet then use the approaches described in other answers for this question.

Hope that helps!

Gary

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
0

The answer Gary provided was correct until the release of 2.8. Starting in 2.8, NuGet will pick the lowest available version. This page was updated to reflect the change.

In NuGet 2.8+, you can now specify a DependencyVersion attribute in your nuspec file to grab the latest. Like so:

<config>
    <add key="dependencyversion" value="Highest" />
</config>

Here is the 2.8 release notes page which goes into more detail.

Chris Dibble
  • 388
  • 1
  • 5
  • 16