From 5073e79ad679e904fd73adfc3b8bc94597521c64 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Tue, 12 Oct 2021 09:51:15 -0700 Subject: [PATCH] Mitigate relative path calculation error on multiple iterations --- eng/common/scripts/Save-Package-Properties.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 10cb4158c01f..b29a6bc02df3 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -48,8 +48,15 @@ function SetOutput($outputPath, $incomingPackageSpec) { else { $outputObject = $incomingPackageSpec + + # Set file paths to relative paths. Only do this if there is no existing + # package info json file as running this multiple times can create + # unexpected relative paths in some scenarios. + $outputObject.DirectoryPath = GetRelativePath $outputObject.DirectoryPath + $outputObject.ReadMePath = GetRelativePath $outputObject.ReadMePath + $outputObject.ChangeLogPath = GetRelativePath $outputObject.ChangeLogPath } - + if ($addDevVersion) { @@ -58,11 +65,6 @@ function SetOutput($outputPath, $incomingPackageSpec) { $outputObject.DevVersion = $incomingPackageSpec.Version } - # Set file paths to relative paths - $outputObject.DirectoryPath = GetRelativePath $outputObject.DirectoryPath - $outputObject.ReadMePath = GetRelativePath $outputObject.ReadMePath - $outputObject.ChangeLogPath = GetRelativePath $outputObject.ChangeLogPath - Set-Content ` -Path $outputPath ` -Value (ConvertTo-Json -InputObject $outputObject -Depth 100)