@@ -51,23 +51,29 @@ if ([string]::IsNullOrWhiteSpace($runtime)) {
51
51
Write-Host " Runtime '$runtime ' mapped to platform(s): $ ( $platforms -join ' , ' ) "
52
52
}
53
53
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
55
55
if ([string ]::IsNullOrWhiteSpace($cliVersion )) {
56
56
Write-Host " CLI version not provided, attempting to extract from artifacts path..."
57
57
58
- $versionPattern = ' ^Azure\.Functions\.Cli\..*?\.(\d+\.\d+\.\d+(?:-(?:ci|beta|rc)[-\.\d]+ )?)$'
58
+ $versionPattern = ' ^Azure\.Functions\.Cli\..*?\.(\d+\.\d+\.\d+(?:-.* )?)$'
59
59
60
60
$cliVersion = Get-ChildItem - Path $artifactsPath - Directory |
61
61
Where-Object { $_.Name -match $versionPattern } |
62
62
Select-Object - First 1 - ExpandProperty Name |
63
63
ForEach-Object { $_ -replace $versionPattern , ' $1' }
64
64
}
65
65
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
-
69
66
Write-Host " CLI Version: $cliVersion "
70
67
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
+
71
77
# Function to process MSI generation for a platform
72
78
function New-PlatformMSI {
73
79
param (
@@ -140,7 +146,7 @@ Get-ChildItem -Path $artifactsPath -Directory | ForEach-Object {
140
146
}
141
147
142
148
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
144
150
$processedPlatforms += $matchedPlatform
145
151
}
146
152
}
@@ -152,7 +158,7 @@ if ($processedPlatforms.Count -eq 0) {
152
158
foreach ($platform in $platforms ) {
153
159
$targetDir = " $artifactsPath \win-$platform "
154
160
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
156
162
$processedPlatforms += $platform
157
163
}
158
164
}
0 commit comments