@@ -14,14 +14,35 @@ steps:
1414 script : |
1515 # Fetch the latest version of the func-cli package from the feed. All packages should have the
1616 # same package version as it is based on the CLI version + build number (which is date based)
17- $packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/a998de77-f16c-4c10-af8c-cfa5a430eae7?api-version=7.1"
1817 $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
1918
20- $response = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get
21- $latestVersion = $response.versions[0].version
22-
23- Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$latestVersion"
24- Write-Host "Using func-cli version: $latestVersion"
19+ function Get-LatestPackageVersion {
20+ param($packageName)
21+
22+ $searchUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages?packageNameQuery=$packageName&api-version=7.1"
23+ $searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get
24+ $package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1
25+
26+ if ($package) {
27+ $packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/$($package.id)?api-version=7.1"
28+ $packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get
29+ return $packageDetails.versions[0].version
30+ }
31+ return $null
32+ }
33+
34+ # Get version for each package
35+ $funcCliVersion = Get-LatestPackageVersion -packageName "func-cli"
36+ Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$funcCliVersion"
37+ Write-Host "func-cli version: $funcCliVersion"
38+
39+ $funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc"
40+ Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion"
41+ Write-Host "func-cli-inproc version: $funcCliInprocVersion"
42+
43+ $funcCliHostVersion = Get-LatestPackageVersion -packageName "func-cli-host"
44+ Write-Host "##vso[task.setvariable variable=FUNC_CLI_HOST_VERSION]$funcCliHostVersion"
45+ Write-Host "func-cli-host version: $funcCliHostVersion"
2546 env :
2647 SYSTEM_ACCESSTOKEN : $(System.AccessToken)
2748
4162 packageType : ' upack'
4263 feed : ' internal/core-tools-nightly-build'
4364 definition : ' func-cli-inproc'
44- version : ' $(FUNC_CLI_VERSION )'
65+ version : ' $(FUNC_CLI_INPROC_VERSION )'
4566 downloadPath : ' $(Pipeline.Workspace)/func-cli-inproc'
4667
4768 - task : DownloadPackage@1
5071 packageType : ' upack'
5172 feed : ' internal/core-tools-nightly-build'
5273 definition : ' func-cli-host'
53- version : ' $(FUNC_CLI_VERSION )'
74+ version : ' $(FUNC_CLI_HOST_VERSION )'
5475 downloadPath : ' $(Pipeline.Workspace)/func-cli-host'
0 commit comments