Skip to content

Commit

Permalink
ensure that empty package properties are not honored when dumping the…
Browse files Browse the repository at this point in the history
…m to json (Azure#39565)

Co-authored-by: Scott Beddall (from Dev Box) <[email protected]>
  • Loading branch information
2 people authored and DevArjun23 committed Nov 14, 2023
1 parent 534d745 commit bc40dd9
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,36 @@ if ($allPackageProperties)
}
foreach($pkg in $allPackageProperties)
{
Write-Host "Package Name: $($pkg.Name)"
Write-Host "Package Version: $($pkg.Version)"
Write-Host "Package SDK Type: $($pkg.SdkType)"
Write-Host "Artifact Name: $($pkg.ArtifactName)"
Write-Host "Release date: $($pkg.ReleaseStatus)"
$configFilePrefix = $pkg.Name
if ($pkg.ArtifactName)
{
$configFilePrefix = $pkg.ArtifactName
if ($pkg.Name) {
Write-Host "Package Name: $($pkg.Name)"
Write-Host "Package Version: $($pkg.Version)"
Write-Host "Package SDK Type: $($pkg.SdkType)"
Write-Host "Artifact Name: $($pkg.ArtifactName)"
Write-Host "Release date: $($pkg.ReleaseStatus)"
$configFilePrefix = $pkg.Name
if ($pkg.ArtifactName)
{
$configFilePrefix = $pkg.ArtifactName
}
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"
Write-Host "Output path of json file: $outputPath"
$outDir = Split-Path $outputPath -parent
if (-not (Test-Path -path $outDir))
{
Write-Host "Creating directory $($outDir) for json property file"
New-Item -ItemType Directory -Path $outDir
}

# If package properties for a track 2 (IsNewSdk = true) package has
# already been written, skip writing to that same path.
if ($exportedPaths.ContainsKey($outputPath) -and $exportedPaths[$outputPath].IsNewSdk -eq $true) {
Write-Host "Track 2 package info with file name $($outputPath) already exported. Skipping export."
continue
}
$exportedPaths[$outputPath] = $pkg

SetOutput $outputPath $pkg
}
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"
Write-Host "Output path of json file: $outputPath"
$outDir = Split-Path $outputPath -parent
if (-not (Test-Path -path $outDir))
{
Write-Host "Creating directory $($outDir) for json property file"
New-Item -ItemType Directory -Path $outDir
}

# If package properties for a track 2 (IsNewSdk = true) package has
# already been written, skip writing to that same path.
if ($exportedPaths.ContainsKey($outputPath) -and $exportedPaths[$outputPath].IsNewSdk -eq $true) {
Write-Host "Track 2 package info with file name $($outputPath) already exported. Skipping export."
continue
}
$exportedPaths[$outputPath] = $pkg

SetOutput $outputPath $pkg
}

Get-ChildItem -Path $outDirectory
Expand Down

0 comments on commit bc40dd9

Please sign in to comment.