From 7be1607b664505b1de109e77f258414f676df0b7 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 6 Jun 2023 16:04:47 +0100 Subject: [PATCH] (build) Handle null value for PreReleaseLabel Depending on what branch is in play, the PreReleaseLabel may not contain a value, as such, we need to handle when this hasn't been set, and only attempt to grab a prerelease value when there is known to be one. --- BuildScripts/default.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BuildScripts/default.ps1 b/BuildScripts/default.ps1 index a21032fa..3481a681 100644 --- a/BuildScripts/default.ps1 +++ b/BuildScripts/default.ps1 @@ -67,7 +67,9 @@ task Run-GitVersion { # Having a pre-release label of greater than 10 characters can cause problems when trying to run choco pack. # Since we typically only see this when building a local feature branch, or a PR, let's just trim it down to # the 10 character limit, and move on. - $prerelease = $versionInfo.PreReleaseLabel.Replace("-","").Substring(0,10) + if ($versionInfo.PreReleaseLabel) { + $prerelease = $versionInfo.PreReleaseLabel.Replace("-","").Substring(0,10) + } # Chocolatey doesn't support a prerelease that starts with a digit. # If we see a digit here, merely replace it with an `a` to get around this.