Skip to content

Commit af2eb8a

Browse files
Avoid overwriting package info properties when dev version is added (#24564)
Co-authored-by: Praveen Kuttappan <praveen.kuttappan@gmail.com>
1 parent 23e95a8 commit af2eb8a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,25 @@ Param (
3737

3838
. (Join-Path $PSScriptRoot common.ps1)
3939

40-
function SetOutput($outputPath, $incomingPackageSpec) {
41-
$outputObject = $incomingPackageSpec
40+
function SetOutput($outputPath, $incomingPackageSpec) {
4241

43-
if ($addDevVersion) {
42+
# If there is an exsiting package info json file read that and set that as output object which gets properties updated here.
43+
if (Test-Path $outputPath)
44+
{
45+
Write-Host "Found existing package info json."
46+
$outputObject = ConvertFrom-Json (Get-Content $outputPath -Raw)
47+
}
48+
else
49+
{
50+
$outputObject = $incomingPackageSpec
51+
}
52+
53+
54+
if ($addDevVersion)
55+
{
4456
# Use the "Version" property which was provided by the incoming package spec
4557
# as the DevVersion. This may be overridden later.
4658
$outputObject.DevVersion = $incomingPackageSpec.Version
47-
48-
# If there is an exsiting package info json file read that and set the
49-
# Version property from that JSON file.
50-
if (Test-Path $outputPath) {
51-
$originalObject = ConvertFrom-Json (Get-Content $outputPath -Raw)
52-
$outputObject.Version = $originalObject.Version
53-
}
5459
}
5560

5661
# Set file paths to relative paths

0 commit comments

Comments
 (0)