Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions pipelines/templates/steps-build-planner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
syrle-foronda marked this conversation as resolved.
Outdated

Write-Host "Computed Version: $version"

Write-Host "##vso[task.setvariable variable=NBGV_SemVer1]$version"
Comment thread
syrle-foronda marked this conversation as resolved.
Outdated
displayName: "Set build version (using Build.BuildId)"
- pwsh: |
$ErrorActionPreference = 'Stop'
$publishDest = "$(Build.ArtifactStagingDirectory)/velopack-input/publish/NetUpgradePlanner"
Expand All @@ -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"
Expand All @@ -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)
17 changes: 15 additions & 2 deletions pipelines/templates/upload-build-planner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
syrle-foronda marked this conversation as resolved.
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"
Expand Down