Skip to content

Commit daf3eda

Browse files
azure-sdkscbedd
andauthored
ensure that empty package properties are not honored when dumping them to json (Azure#32809)
Co-authored-by: Scott Beddall (from Dev Box) <[email protected]>
1 parent 95df079 commit daf3eda

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

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

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -101,34 +101,36 @@ if ($allPackageProperties)
101101
}
102102
foreach($pkg in $allPackageProperties)
103103
{
104-
Write-Host "Package Name: $($pkg.Name)"
105-
Write-Host "Package Version: $($pkg.Version)"
106-
Write-Host "Package SDK Type: $($pkg.SdkType)"
107-
Write-Host "Artifact Name: $($pkg.ArtifactName)"
108-
Write-Host "Release date: $($pkg.ReleaseStatus)"
109-
$configFilePrefix = $pkg.Name
110-
if ($pkg.ArtifactName)
111-
{
112-
$configFilePrefix = $pkg.ArtifactName
104+
if ($pkg.Name) {
105+
Write-Host "Package Name: $($pkg.Name)"
106+
Write-Host "Package Version: $($pkg.Version)"
107+
Write-Host "Package SDK Type: $($pkg.SdkType)"
108+
Write-Host "Artifact Name: $($pkg.ArtifactName)"
109+
Write-Host "Release date: $($pkg.ReleaseStatus)"
110+
$configFilePrefix = $pkg.Name
111+
if ($pkg.ArtifactName)
112+
{
113+
$configFilePrefix = $pkg.ArtifactName
114+
}
115+
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"
116+
Write-Host "Output path of json file: $outputPath"
117+
$outDir = Split-Path $outputPath -parent
118+
if (-not (Test-Path -path $outDir))
119+
{
120+
Write-Host "Creating directory $($outDir) for json property file"
121+
New-Item -ItemType Directory -Path $outDir
122+
}
123+
124+
# If package properties for a track 2 (IsNewSdk = true) package has
125+
# already been written, skip writing to that same path.
126+
if ($exportedPaths.ContainsKey($outputPath) -and $exportedPaths[$outputPath].IsNewSdk -eq $true) {
127+
Write-Host "Track 2 package info with file name $($outputPath) already exported. Skipping export."
128+
continue
129+
}
130+
$exportedPaths[$outputPath] = $pkg
131+
132+
SetOutput $outputPath $pkg
113133
}
114-
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"
115-
Write-Host "Output path of json file: $outputPath"
116-
$outDir = Split-Path $outputPath -parent
117-
if (-not (Test-Path -path $outDir))
118-
{
119-
Write-Host "Creating directory $($outDir) for json property file"
120-
New-Item -ItemType Directory -Path $outDir
121-
}
122-
123-
# If package properties for a track 2 (IsNewSdk = true) package has
124-
# already been written, skip writing to that same path.
125-
if ($exportedPaths.ContainsKey($outputPath) -and $exportedPaths[$outputPath].IsNewSdk -eq $true) {
126-
Write-Host "Track 2 package info with file name $($outputPath) already exported. Skipping export."
127-
continue
128-
}
129-
$exportedPaths[$outputPath] = $pkg
130-
131-
SetOutput $outputPath $pkg
132134
}
133135

134136
Get-ChildItem -Path $outDirectory

0 commit comments

Comments
 (0)