From eb2fab16a0712d3dc529805ec9d48ecabf15ac4f Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 8 Oct 2021 14:50:22 -0700 Subject: [PATCH] Avoid overwriting package info properties when dev version is added (#2957) Co-authored-by: Praveen Kuttappan --- .../scripts/Save-Package-Properties.ps1 | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 7e5181383..10cb4158c 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -37,20 +37,25 @@ Param ( . (Join-Path $PSScriptRoot common.ps1) -function SetOutput($outputPath, $incomingPackageSpec) { - $outputObject = $incomingPackageSpec +function SetOutput($outputPath, $incomingPackageSpec) { - if ($addDevVersion) { + # If there is an exsiting package info json file read that and set that as output object which gets properties updated here. + if (Test-Path $outputPath) + { + Write-Host "Found existing package info json." + $outputObject = ConvertFrom-Json (Get-Content $outputPath -Raw) + } + else + { + $outputObject = $incomingPackageSpec + } + + + if ($addDevVersion) + { # Use the "Version" property which was provided by the incoming package spec # as the DevVersion. This may be overridden later. $outputObject.DevVersion = $incomingPackageSpec.Version - - # If there is an exsiting package info json file read that and set the - # Version property from that JSON file. - if (Test-Path $outputPath) { - $originalObject = ConvertFrom-Json (Get-Content $outputPath -Raw) - $outputObject.Version = $originalObject.Version - } } # Set file paths to relative paths