From a7eabe6b34b33ad4f1501d21f0265524ac0d6eb1 Mon Sep 17 00:00:00 2001 From: Syrle Foronda Date: Thu, 25 Jun 2026 12:25:22 -0700 Subject: [PATCH 1/4] Handle vpk packaging conflicts for Planner Wrap vpk pack in a try/catch to detect and handle duplicate-version conflicts. Adds logging for attempts and success, sets PlannerVersionExists=true when the error indicates the version already exists (matches "equal or greater" or HTTP 409), and rethrows other errors. This prevents the pipeline from failing when attempting to upload an already-published Planner package while preserving the PlannerVersion variable. --- pipelines/templates/upload-build-planner.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pipelines/templates/upload-build-planner.yml b/pipelines/templates/upload-build-planner.yml index 0c0668dc..6bf4c422 100644 --- a/pipelines/templates/upload-build-planner.yml +++ b/pipelines/templates/upload-build-planner.yml @@ -59,8 +59,21 @@ steps: Write-Host "##vso[task.setvariable variable=PlannerVersion]$version" } else { - vpk pack --packId "NetUpgradePlanner" --packTitle ".NET Upgrade Planner" --packVersion "$version" --packAuthors "Immo Landwerth" --packDir "." --framework net8-x64-desktop --mainExe NetUpgradePlanner.exe --outputDir "$releaseDir" - Write-Host "##vso[task.setvariable variable=PlannerVersionExists]false" + Write-Host "Attempting to package version $version..." + try { + vpk pack --packId "NetUpgradePlanner" --packTitle ".NET Upgrade Planner" --packVersion "$version" --packAuthors "Immo Landwerth" --packDir "." --framework net8-x64-desktop --mainExe NetUpgradePlanner.exe --outputDir "$releaseDir" + Write-Host "Successfully packaged version $version" + Write-Host "##vso[task.setvariable variable=PlannerVersionExists]false" + } + catch { + if ($_ -match "equal or greater" -or $_ -match "409") { + Write-Host "Version $version already exists in release channel; skipping to avoid conflict." + Write-Host "##vso[task.setvariable variable=PlannerVersionExists]true" + } + else { + throw $_ + } + } Write-Host "##vso[task.setvariable variable=PlannerVersion]$version" } displayName: "vpk pack" From 8bb5f593a42a81d37babe25c8ddb524d5a4b4180 Mon Sep 17 00:00:00 2001 From: Syrle Foronda Date: Thu, 25 Jun 2026 13:38:30 -0700 Subject: [PATCH 2/4] Use Build.BuildId for planner versioning Replace nbgv-based versioning with a deterministic version computed from Build.BuildId and the commit hash (format: 0.1.-beta+). This removes the nbgv tool install/update steps, exposes the computed version as the NBGV_SemVer1 pipeline variable for later steps, and updates error messages to reflect the new variable/flow and avoid references to unexpanded nbgv output. --- pipelines/templates/steps-build-planner.yml | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pipelines/templates/steps-build-planner.yml b/pipelines/templates/steps-build-planner.yml index 80895fc7..9609d178 100644 --- a/pipelines/templates/steps-build-planner.yml +++ b/pipelines/templates/steps-build-planner.yml @@ -11,13 +11,16 @@ steps: version: 8.x - pwsh: | $ErrorActionPreference = 'Stop' - $config = "$(Build.SourcesDirectory)/src/nuget.config" - dotnet tool update -g nbgv --configfile $config - if ($LASTEXITCODE -ne 0) { - dotnet tool install -g nbgv --configfile $config - } - nbgv cloud -p ${{ parameters.projectPath }} -a - displayName: "Set build version (nbgv)" + + # Use Build.BuildId for versioning to ensure monotonically increasing versions + $buildId = "$(Build.BuildId)" + $gitHash = "$(Build.SourceVersion)".Substring(0, 10) + $version = "0.1.$buildId-beta+$gitHash" + + Write-Host "Computed Version: $version" + + Write-Host "##vso[task.setvariable variable=NBGV_SemVer1]$version" + displayName: "Set build version (using Build.BuildId)" - pwsh: | $ErrorActionPreference = 'Stop' $publishDest = "$(Build.ArtifactStagingDirectory)/velopack-input/publish/NetUpgradePlanner" @@ -27,14 +30,14 @@ steps: displayName: "dotnet publish" - pwsh: | $ErrorActionPreference = 'Stop' - $version = $env:PLANNER_SEMVER1 + $version = $env:NBGV_SemVer1 if ([string]::IsNullOrWhiteSpace($version)) { - throw "NBGV version variable is missing. Ensure 'nbgv cloud -p ${{ parameters.projectPath }} -a' completed successfully." + throw "Build version is empty. Ensure the 'Set build version' step executed successfully." } if ($version -match '^\$\(') { - throw "NBGV version variable was not expanded (got literal '$version'). Ensure 'nbgv cloud -p ${{ parameters.projectPath }} -a' ran with the -a/--all-vars flag so NBGV_SemVer1 is published." + throw "Build version was not expanded (got literal '$version'). Ensure pipeline variables are properly set." } $inputRoot = "$(Build.ArtifactStagingDirectory)/velopack-input" @@ -43,4 +46,4 @@ steps: Copy-Item -Path "$(Build.SourcesDirectory)/src/nuget.config" -Destination (Join-Path $inputRoot "nuget.config") -Force displayName: "Prepare velopack inputs" env: - PLANNER_SEMVER1: $(NBGV_SemVer1) + NBGV_SemVer1: $(NBGV_SemVer1) From e71a190fefc70ccb558fd70d30c38e615d97218d Mon Sep 17 00:00:00 2001 From: Syrle Foronda Date: Thu, 9 Jul 2026 12:28:59 -0700 Subject: [PATCH 3/4] Release planner as stable and improve error handling Remove the '-beta' suffix from the version string to release as a stable version. Rename the version variable from NBGV_SemVer1 to PlannerSemVer for clarity. Add error checking for the vpk tool availability and the vpk pack command execution. --- pipelines/templates/steps-build-planner.yml | 8 ++++---- pipelines/templates/upload-build-planner.yml | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pipelines/templates/steps-build-planner.yml b/pipelines/templates/steps-build-planner.yml index 9609d178..6daea622 100644 --- a/pipelines/templates/steps-build-planner.yml +++ b/pipelines/templates/steps-build-planner.yml @@ -15,11 +15,11 @@ steps: # Use Build.BuildId for versioning to ensure monotonically increasing versions $buildId = "$(Build.BuildId)" $gitHash = "$(Build.SourceVersion)".Substring(0, 10) - $version = "0.1.$buildId-beta+$gitHash" + $version = "0.1.$buildId+$gitHash" Write-Host "Computed Version: $version" - Write-Host "##vso[task.setvariable variable=NBGV_SemVer1]$version" + Write-Host "##vso[task.setvariable variable=PlannerSemVer]$version" displayName: "Set build version (using Build.BuildId)" - pwsh: | $ErrorActionPreference = 'Stop' @@ -30,7 +30,7 @@ steps: displayName: "dotnet publish" - pwsh: | $ErrorActionPreference = 'Stop' - $version = $env:NBGV_SemVer1 + $version = $env:PlannerSemVer if ([string]::IsNullOrWhiteSpace($version)) { throw "Build version is empty. Ensure the 'Set build version' step executed successfully." @@ -46,4 +46,4 @@ steps: Copy-Item -Path "$(Build.SourcesDirectory)/src/nuget.config" -Destination (Join-Path $inputRoot "nuget.config") -Force displayName: "Prepare velopack inputs" env: - NBGV_SemVer1: $(NBGV_SemVer1) + PlannerSemVer: $(PlannerSemVer) diff --git a/pipelines/templates/upload-build-planner.yml b/pipelines/templates/upload-build-planner.yml index 6bf4c422..9abf0dfb 100644 --- a/pipelines/templates/upload-build-planner.yml +++ b/pipelines/templates/upload-build-planner.yml @@ -60,8 +60,15 @@ steps: } else { Write-Host "Attempting to package version $version..." + if($LASTEXITCODE -ne 0) { + throw "vpk tool is not available. Ensure it is installed and in the PATH." + } try { vpk pack --packId "NetUpgradePlanner" --packTitle ".NET Upgrade Planner" --packVersion "$version" --packAuthors "Immo Landwerth" --packDir "." --framework net8-x64-desktop --mainExe NetUpgradePlanner.exe --outputDir "$releaseDir" + if ($LASTEXITCODE -ne 0) { + throw "vpk pack failed with exit code $LASTEXITCODE." + } + Write-Host "Successfully packaged version $version" Write-Host "##vso[task.setvariable variable=PlannerVersionExists]false" } From 24480b49085bdf93dfb7fbca0f1d0bf28a550dc6 Mon Sep 17 00:00:00 2001 From: Syrle Foronda Date: Thu, 9 Jul 2026 15:25:01 -0700 Subject: [PATCH 4/4] fix error --- pipelines/templates/upload-build-planner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/templates/upload-build-planner.yml b/pipelines/templates/upload-build-planner.yml index 9abf0dfb..80807bc9 100644 --- a/pipelines/templates/upload-build-planner.yml +++ b/pipelines/templates/upload-build-planner.yml @@ -60,7 +60,7 @@ steps: } else { Write-Host "Attempting to package version $version..." - if($LASTEXITCODE -ne 0) { + if (-not (Get-Command vpk -ErrorAction SilentlyContinue)) { throw "vpk tool is not available. Ensure it is installed and in the PATH." } try {