Skip to content

Commit 5b5024c

Browse files
committed
Fix MSI versioning (#4630)
1 parent 25ed847 commit 5b5024c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

eng/scripts/generate-msi-files.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,29 @@ if ([string]::IsNullOrWhiteSpace($runtime)) {
5151
Write-Host "Runtime '$runtime' mapped to platform(s): $($platforms -join ', ')"
5252
}
5353

54-
# Try and get the CLI version from the folder name if not provided
54+
# 1) Try and get the CLI version from the folder name if not provided
5555
if ([string]::IsNullOrWhiteSpace($cliVersion)) {
5656
Write-Host "CLI version not provided, attempting to extract from artifacts path..."
5757

58-
$versionPattern = '^Azure\.Functions\.Cli\..*?\.(\d+\.\d+\.\d+(?:-(?:ci|beta|rc)[-\.\d]+)?)$'
58+
$versionPattern = '^Azure\.Functions\.Cli\..*?\.(\d+\.\d+\.\d+(?:-.*)?)$'
5959

6060
$cliVersion = Get-ChildItem -Path $artifactsPath -Directory |
6161
Where-Object { $_.Name -match $versionPattern } |
6262
Select-Object -First 1 -ExpandProperty Name |
6363
ForEach-Object { $_ -replace $versionPattern, '$1' }
6464
}
6565

66-
# If the version has -ci.x.y, convert it to .x to ensure we have a valid MSI version format
67-
$cliVersion = $cliVersion -replace '-(?:ci|beta|rc|dev)\.([0-9]+)\.0$', '.$1'
68-
6966
Write-Host "CLI Version: $cliVersion"
7067

68+
# TODO: Design MSI versioning strategy for pre-release: https://github.com/Azure/azure-functions-core-tools/issues/4627
69+
# 2) For MSI: strip anything after a dash (-)
70+
# Example: 4.2.2-ci.25429.0 -> 4.2.2
71+
# 4.2.2-preview1 -> 4.2.2
72+
# 4.2.2 -> 4.2.2
73+
$msiVersion = $cliVersion -replace '^(\d+\.\d+\.\d+).*$', '$1'
74+
75+
Write-Host "MSI Version: $msiVersion"
76+
7177
# Function to process MSI generation for a platform
7278
function New-PlatformMSI {
7379
param(
@@ -140,7 +146,7 @@ Get-ChildItem -Path $artifactsPath -Directory | ForEach-Object {
140146
}
141147

142148
if ($matchedPlatform) {
143-
New-PlatformMSI -TargetDir $subDir -Platform $matchedPlatform -CliVersion $cliVersion -ResourceDir $resourceDir -ArtifactsPath $artifactsPath
149+
New-PlatformMSI -TargetDir $subDir -Platform $matchedPlatform -CliVersion $msiVersion -ResourceDir $resourceDir -ArtifactsPath $artifactsPath
144150
$processedPlatforms += $matchedPlatform
145151
}
146152
}
@@ -152,7 +158,7 @@ if ($processedPlatforms.Count -eq 0) {
152158
foreach ($platform in $platforms) {
153159
$targetDir = "$artifactsPath\win-$platform"
154160
if (Test-Path $targetDir) {
155-
New-PlatformMSI -TargetDir $targetDir -Platform $platform -CliVersion $cliVersion -ResourceDir $resourceDir -ArtifactsPath $artifactsPath
161+
New-PlatformMSI -TargetDir $targetDir -Platform $platform -CliVersion $msiVersion -ResourceDir $resourceDir -ArtifactsPath $artifactsPath
156162
$processedPlatforms += $platform
157163
}
158164
}

0 commit comments

Comments
 (0)