Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having a dependency on a specific nuget package

Tags:

nuget

We have a bunch of internal packages that we create for other teams to consume, and many of these have dependencies on open sources packages. I would like to add a dependency to a specific version of a nuget package to my nuspec, such that when the end user installs my package the dependent packages get installed too.

My <dependencies> section of my nuspec looks like this:

<dependencies>
  <dependency id="MassTransit" version="2.0.0.4" />
  <dependency id="MassTransit.RabbitMQ" version="2.0.0.4" />
</dependencies>

Which I was hoping would bring down only version 2.0.0.4 of MassTransit, however it brings down 2.0.0.5, which my application currently doesn't work with. I've tried the following formats, but none of them seem to work:

version="[2.0.0.4, 2.0.0.5)"
version="[2.0.0.4]"
version="2.0.0.5)"

Infact, I can't seem to get anything in the documentation about version ranges to work properly.

I do have one thought, which is that masstransit is using a 4 digit version number, while all the examples are 3 digits a-la semver. Is this what could be causing my problem?

Edit:

It turns out the version of nuget on the build server was out of date and didn't support the ranges I wanted to use. Upgrading it fixed everything!

like image 403
jonnii Avatar asked Sep 28 '11 22:09

jonnii


People also ask

What is dependency in NuGet?

Any time a package is installed or reinstalled, which includes being installed as part of a restore process, NuGet also installs any additional packages on which that first package depends. Those immediate dependencies might then also have dependencies on their own, which can continue to an arbitrary depth.

How do I update NuGet dependencies?

By Command-line: You can download nuget.exe,and add the path where it exists to Path system environment variables. Then you could simply reference the nuget.exe directly. After that you can use command like nuget update YourSolution. sln in Package Manager Console to update the dependencies for solution.

Where are NuGet packages references stored?

The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux).


1 Answers

No, doing something like [version] should get you the exact version.

like image 110
davidfowl Avatar answered Oct 26 '22 23:10

davidfowl