9
votes

The scenario is package management with NuGet.

Suppose you have PackageA that depends on PackageB, you publish both of them so whenever you publish PackageA, you specify the version range of Package B you depends on.

Now both of the packages are automatically published with a Build, and they use SemVer (GitVersion.exe), version 6.0.0 of PackageA declares that it needs at least version 6.0.0 of Package B. This works perfectly if packages are in stable version.

Actually no 6.x.x stable version exists for both package and if I'm installing the prerelease version of PackageA it complains because it needs at least version 6.0.0 of packageB, but packageB has only 6.0.0-prerelease version.

Here is the error.

Unable to resolve dependencies. 'PackageB 6.0.0-unstable0066' is not compatible with 'PackageA 6.0.0-unstable0015 constraint: PackageB (>= 6.0.0)'.

My question is, how is the correct way to manage dependencies from pre-release version of packages?

Thanks.

1
Actually that problem is due to the fact that, prerelease 6.0.0 versions are considered to be lower number than 6.0.0, and it makes sense, because they are not stable. This lead to a possible answer, 6.0.0 prerelease version of PackageA should declare dependency to a version greater than the latest stable of PackageB, but it could be a pain to automatically handle in the build. - Alkampfer
Did you try defining a pre-release version constraint on your dependency? <dependency id="PackageB" version="[6.0.0-unstable00011,)" /> - Matt Ward
actually I've solved requiring a version greatest than the latest published number of the old release. So If the latest 5.x version is 5.4, the 6.0 package requires minimum version of 5.5. this includes automatically all the 6.0.0-xxxxxxx - Alkampfer
I would add how you solved it as the answer. - Matt Ward
Actually is not a really good solution so I do not think it worth to be posted. - Alkampfer

1 Answers

2
votes

For me, this is a clear bug at NuGet, because even if you explicitly add a reference to PackageB 6.0.0-unstablewhatever, NuGet claims that the packages are incomatible.

Or, to be more precise, it does that if you are using package references. If you use the old package.config format, NuGet is happy to accept the prerelease package.