4
Vote

NuGet imposes artificial max string length of 20 characters for "SpecialVersion" (aka pre-release)

description

Just ran into a problem where we have a base pre-release identifier of something like 16 characters, but then, in order to create a newer version, we usually append a yyyyMMddbb string to those which send it over 20 characters and got an InvalidOperationException from NuGet telling me it exceeds 20 characters.

The offending logic is in PackageBuilder::ValidateSpecialVersionLength which is called by PackageBuilder::Save. I see no mention of a maximum string length for pre-release identifiers in the SemVer specification (either v1 or the new v2), therefore this check should not even exist. The only mention in the v2 spec is that the entire version string should not exceed 255 characters in total string length.

comments

dmarsh wrote Jun 21, 2013 at 6:20 PM

PR submitted.

dotnetjunky wrote Jun 21, 2013 at 11:30 PM

We think 20 characters is sufficient for the special string. Changing it now will also require changing the code on nuget.org to accommodate for longer string.

Please modify your build so that it fits into 20 characters limit.

dotnetjunky wrote Jun 21, 2013 at 11:30 PM

** Closed by dotnetjunky 06/21/2013 4:30PM

dmarsh wrote Jun 21, 2013 at 11:54 PM

We have changed our identifier already, so this is a forward thinking recommendation.

It seems odd to me that the NuGet team to declare that 20 characters is enough for everybody in the world, especially when supposedly trying to abide by SemVer versioning rules which has no such specified restriction. Now, maybe you want to impose the restriction for NuGet.org itself and, ok, that's totally up to you. In fact, for my use case (and probably that of many others), I'm not publishing my pre-release packages to the official NuGet feed anyway. However, I don't see why such a limitation it needs to be imposed within in NuGet Core such that third parties can't even build their own packages with IDs of their choosing.

The truth is this only a bigger problem for because I'm forced to append a build number to the static pre-release identifier. Once NuGet has support for SemVer 2.0 build #s this will probably become a non-issue for me, though I still see no good reason to impose the restriction in NuGet Core.

JeffHandley wrote Jun 22, 2013 at 2:10 AM

Thanks for raising this as an issue and sharing your feedback. This is something I brought up within the SemVer spec itself, which led to that 255-character total length limit.

https://github.com/mojombo/semver/issues/79

While we have an arbitrary length limit now, I'm not comfortable just picking another (longer) arbitrary limit at the moment. We'll be thinking about SemVer 2.0 support and it would be best to define a new length as part of the spec for that.

PombeirP wrote Feb 19 at 1:58 PM

+1. This makes us jumps through hoops with our internal builds since we can't convey our feature branch names consistently.

Jo8n wrote Aug 19 at 9:32 PM

We've also run into trouble with this for our internal builds and packages. By the time we include the defect number, we only have 12 characters for other info. If this is merely because longer values are "ugly", as 1639 implies, that seems very arbitrary and I would think ugliness should be handled in presentation.
Thanks.

CaioProiete wrote Sep 7 at 1:50 AM

@dotnetjunky: Could we revisit this, please?

Would be great to remove this limitation of 20 chars which hurts a lot of people building NuGet packages for feature branches (where branch name is included as part of the "SpecialVersion".

E.g.
MyApp.1.2.0.76-JIRA-6541-some-meaningful-description-about-the-feature.nupkg

Of course we can truncate it, but then there's much less value as you can't tell immediately what the package is/has:
MyApp.1.2.0.76-JIRA-6541-some-meani

Thanks,
Caio Proiete

ianbattersby wrote Sep 22 at 9:12 AM

+1 - Please don't enforce an artificial limit, or at least provide an override flag. This is now killing my chosen workflow because I'm a couple of characters over :(