Skip to content

Commit ab2507b

Browse files
Sync eng/common directory with azure-sdk-tools for PR 2095 (Azure#24749)
* Mitigate relative path calculation error on multiple iterations * Revert "Mitigate relative path calculation error on multiple iterations" This reverts commit 45baedd990c6a3085742a38a4891d8706a93be77. * GetRelativePath should check if path is already relative before calling [IO.Path]::GetRelativePath Co-authored-by: Daniel Jurek <djurek@microsoft.com>
1 parent faf50e9 commit ab2507b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

eng/common/scripts/Save-Package-Properties.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ function GetRelativePath($path) {
7373
if (!$path) {
7474
return ''
7575
}
76+
77+
# If the path is already relative return the path. Calling `GetRelativePath`
78+
# on a relative path converts the relative path to an absolute path based on
79+
# the current working directory which can result in unexpected outputs.
80+
if (![IO.Path]::IsPathRooted($path)) {
81+
return $path
82+
}
83+
7684
$relativeTo = Resolve-Path $PSScriptRoot/../../../
7785
# Replace "\" with "/" so the path is valid across other platforms and tools
7886
$relativePath = [IO.Path]::GetRelativePath($relativeTo, $path) -replace "\\", '/'

0 commit comments

Comments
 (0)