From 2694c04ccb375c95be02b0140ac72170f0435c56 Mon Sep 17 00:00:00 2001 From: Jonathan Horvath Date: Tue, 16 Sep 2025 08:25:41 -0400 Subject: [PATCH] Complete PowerShell script path resolution fixes for Azure DevOps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add fallback path resolution to all three version management scripts - Use explicit -BuildPropsPath parameters in CI pipeline calls - Ensures robust operation when PSScriptRoot is unavailable - All scripts now work correctly in Azure DevOps environment 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- ci/package.yml | 6 +++--- scripts/Get-Version.ps1 | 7 ++++++- scripts/Increment-Version.ps1 | 7 ++++++- scripts/Set-Version.ps1 | 7 ++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ci/package.yml b/ci/package.yml index 5c8a55d6..0bffd4ec 100644 --- a/ci/package.yml +++ b/ci/package.yml @@ -74,14 +74,14 @@ steps: git config --global user.name "Azure DevOps Build Agent" # Get current version for display - $currentVersion = & "$(Build.SourcesDirectory)/scripts/Get-Version.ps1" -Format Simple + $currentVersion = & "$(Build.SourcesDirectory)/scripts/Get-Version.ps1" -BuildPropsPath "$(Build.SourcesDirectory)/Directory.Build.props" -Format Simple Write-Host "Packaging completed successfully. Current version: $currentVersion" # Increment patch version - & "$(Build.SourcesDirectory)/scripts/Increment-Version.ps1" -IncrementType Patch + & "$(Build.SourcesDirectory)/scripts/Increment-Version.ps1" -BuildPropsPath "$(Build.SourcesDirectory)/Directory.Build.props" -IncrementType Patch # Get new version - $newVersion = & "$(Build.SourcesDirectory)/scripts/Get-Version.ps1" -Format Simple + $newVersion = & "$(Build.SourcesDirectory)/scripts/Get-Version.ps1" -BuildPropsPath "$(Build.SourcesDirectory)/Directory.Build.props" -Format Simple Write-Host "New version: $newVersion" # Set pipeline variable for later use diff --git a/scripts/Get-Version.ps1 b/scripts/Get-Version.ps1 index 0bf5f75c..dd790007 100644 --- a/scripts/Get-Version.ps1 +++ b/scripts/Get-Version.ps1 @@ -26,7 +26,12 @@ param( # Set default path if not provided if (-not $BuildPropsPath) { - $BuildPropsPath = Join-Path $PSScriptRoot ".." "Directory.Build.props" + if ($PSScriptRoot) { + $BuildPropsPath = Join-Path $PSScriptRoot ".." "Directory.Build.props" + } else { + # Fallback for cases where PSScriptRoot is not available + $BuildPropsPath = Join-Path (Get-Location) "Directory.Build.props" + } } function Get-Version { diff --git a/scripts/Increment-Version.ps1 b/scripts/Increment-Version.ps1 index 63f2a5a9..b1a841cd 100644 --- a/scripts/Increment-Version.ps1 +++ b/scripts/Increment-Version.ps1 @@ -28,7 +28,12 @@ param( # Set default path if not provided if (-not $BuildPropsPath) { - $BuildPropsPath = Join-Path $PSScriptRoot ".." "Directory.Build.props" + if ($PSScriptRoot) { + $BuildPropsPath = Join-Path $PSScriptRoot ".." "Directory.Build.props" + } else { + # Fallback for cases where PSScriptRoot is not available + $BuildPropsPath = Join-Path (Get-Location) "Directory.Build.props" + } } function Get-CurrentVersion { diff --git a/scripts/Set-Version.ps1 b/scripts/Set-Version.ps1 index f1f451a8..8040e4bb 100644 --- a/scripts/Set-Version.ps1 +++ b/scripts/Set-Version.ps1 @@ -25,7 +25,12 @@ param( # Set default path if not provided if (-not $BuildPropsPath) { - $BuildPropsPath = Join-Path $PSScriptRoot ".." "Directory.Build.props" + if ($PSScriptRoot) { + $BuildPropsPath = Join-Path $PSScriptRoot ".." "Directory.Build.props" + } else { + # Fallback for cases where PSScriptRoot is not available + $BuildPropsPath = Join-Path (Get-Location) "Directory.Build.props" + } } function Validate-Version {