Skip to content

Commit 48ccca9

Browse files
committed
trick for chocolatey version format when the prereleasetag is a number
1 parent 66e34e5 commit 48ccca9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

build/common/Utilities/Models.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ public static BuildVersion Calculate(GitVersion gitVersion)
2424

2525
if (!string.IsNullOrWhiteSpace(gitVersion.PreReleaseTag))
2626
{
27-
chocolateyVersion += $"-{gitVersion.PreReleaseTag?.Replace(".", "-")}";
27+
// Chocolatey does not support pre-release tags with dots, so we replace them with dashes
28+
// if the pre-release tag is a number, we add a "a" prefix to the pre-release tag
29+
// the trick should be removed when Chocolatey supports semver 2.0
30+
var prefix = int.TryParse(gitVersion.PreReleaseLabel, out _) ? "a" : string.Empty;
31+
chocolateyVersion += $"-{prefix}{gitVersion.PreReleaseTag?.Replace(".", "-")}";
2832
}
2933

3034
if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaData))

0 commit comments

Comments
 (0)