From 811e0c19c42f6ca37d555831e8248427d8c3f39e Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 19 Jul 2023 20:50:49 +0000 Subject: [PATCH 1/2] Only save package properties for track 2 packages (prevents overwrites of track 2 package info by track 1 packages) --- eng/common/scripts/Save-Package-Properties.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 6fb9e61ee0f2..aae6be94f625 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -88,13 +88,17 @@ function GetRelativePath($path) { } $allPackageProperties = Get-AllPkgProperties $serviceDirectory -if ($allPackageProperties) + +# Only export package info JSON files for track 2 packages +$targetPackages = $allPackageProperties.Where({ $_.IsNewSdk }) + +if ($targetPackages) { if (-not (Test-Path -Path $outDirectory)) { New-Item -ItemType Directory -Force -Path $outDirectory } - foreach($pkg in $allPackageProperties) + foreach($pkg in $targetPackages) { Write-Host "Package Name: $($pkg.Name)" Write-Host "Package Version: $($pkg.Version)" From aaf5f1dc97f946957bb0ff8b1cf8369687a6f41d Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 19 Jul 2023 21:11:16 +0000 Subject: [PATCH 2/2] Only overwrite if the package is track 2 --- .../scripts/Save-Package-Properties.ps1 | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index aae6be94f625..44f622357753 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -10,6 +10,10 @@ an artifact name property is available in the package properties. Can optionally add a dev version property which can be used logic for daily builds. +In cases of collisions where track 2 packages (IsNewSdk = true) have the same +filename as track 1 packages (e.g. same artifact name or package name), the +track 2 package properties will be written. + .PARAMETER serviceDirectory Service directory in which to search for packages @@ -87,18 +91,15 @@ function GetRelativePath($path) { return $relativePath } +$exportedPaths = @{} $allPackageProperties = Get-AllPkgProperties $serviceDirectory - -# Only export package info JSON files for track 2 packages -$targetPackages = $allPackageProperties.Where({ $_.IsNewSdk }) - -if ($targetPackages) +if ($allPackageProperties) { if (-not (Test-Path -Path $outDirectory)) { New-Item -ItemType Directory -Force -Path $outDirectory } - foreach($pkg in $targetPackages) + foreach($pkg in $allPackageProperties) { Write-Host "Package Name: $($pkg.Name)" Write-Host "Package Version: $($pkg.Version)" @@ -118,6 +119,15 @@ if ($targetPackages) 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 }