andreas
andreas

Reputation: 157

Padding versioning with zeros in C# csproj

I have a project (C#) which follows Semantic Versioning (v1). In csproj I have AssemblyInformationalVersion="$(Major).$(Minor).$(Build)-$(RevProp)$(Revision)

RevProp might be Alpha, Beta, RC etc. Revision is the revision number.

According to SemVer 1.0 which is supported by older versions of nuget to create packages, the packages are lexicographically sorted. So when we have the following:

1.0.0-alpha5

1.0.0-alpha10

Nugget will think that 1.0.0-alpha5 is newer, because of its alphabetic order. Thus, I want to pad that number with zeros. Therefore, in the csproj, I want to be able to create the following:

1.0.0-alpha005

1.0.0-alpha010

Is there a way to do this at the project file?

Upvotes: 4

Views: 223

Answers (1)

jwdonahue
jwdonahue

Reputation: 6659

Is there a way to do this at the project file?

I hope not. If you want numeric sorting, use a dot to separate the numeric field from the alphanumeric field. Numeric fields sort numerically. Don't use antique versions of Nuget!

Upvotes: 1

Related Questions