From 354f923d4903c9189cc116beb41601982ce9308a Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 4 Dec 2025 18:04:36 +0000 Subject: [PATCH 1/5] Added optional artifact list to filter the package info to be returned --- .../scripts/Save-Package-Properties.ps1 | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 7734f9ec3cba..62cc761dfb47 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -31,6 +31,10 @@ exists, read the Version property from the existing package properties JSON file and set that as the Version property for the new output. This has the effect of "adding" a DevVersion property to the file which could be different from the Verison property in that file. + +.PARAMETER artifactList +Optional array of artifact names to filter the package properties. Only packages +with artifact names matching entries in this list will be processed. #> [CmdletBinding()] @@ -39,7 +43,8 @@ Param ( [Parameter(Mandatory = $True)] [string] $outDirectory, [string] $prDiff, - [switch] $addDevVersion + [switch] $addDevVersion, + [array] $artifactList ) . (Join-Path $PSScriptRoot common.ps1) @@ -132,6 +137,28 @@ if (-not (Test-Path -Path $outDirectory)) New-Item -ItemType Directory -Force -Path $outDirectory | Out-Null } +if ($artifactList) +{ + # Filter out null, empty, or whitespace-only entries + $filteredArtifacts = @($artifactList | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) + + if ($filteredArtifacts.Count -eq 0) + { + Write-Warning "Artifact list contains no valid entries" + exit 1 + } + + Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')" + $artifactSet = [System.Collections.Generic.HashSet[string]]::new($filteredArtifacts, [System.StringComparer]::OrdinalIgnoreCase) + $allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) } + + if (!$allPackageProperties) + { + Write-Error "No packages found matching the provided artifact list" + exit 1 + } +} + foreach ($pkg in $allPackageProperties) { if ($pkg.Name) From cacd96eda826dc9e40b153302653ee544be95537 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Thu, 4 Dec 2025 10:15:04 -0800 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- eng/common/scripts/Save-Package-Properties.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 62cc761dfb47..e68aaa433cf6 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -30,7 +30,7 @@ package properties JSON file. If the package properties JSON file already exists, read the Version property from the existing package properties JSON file and set that as the Version property for the new output. This has the effect of "adding" a DevVersion property to the file which could be different from the -Verison property in that file. +Version property in that file. .PARAMETER artifactList Optional array of artifact names to filter the package properties. Only packages @@ -150,6 +150,12 @@ if ($artifactList) Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')" $artifactSet = [System.Collections.Generic.HashSet[string]]::new($filteredArtifacts, [System.StringComparer]::OrdinalIgnoreCase) + + # Warn about packages missing ArtifactName property + $missingArtifactName = $allPackageProperties | Where-Object { -not $_.PSObject.Properties.Match('ArtifactName') } + foreach ($pkg in $missingArtifactName) { + Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering." + } $allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) } if (!$allPackageProperties) From 4569847f1beb309ae19827b8cdb9e99e918b22e8 Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 4 Dec 2025 18:21:13 +0000 Subject: [PATCH 3/5] return full package info if the input artifact list is empty --- .../scripts/Save-Package-Properties.ps1 | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index e68aaa433cf6..69e052697c55 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -145,23 +145,24 @@ if ($artifactList) if ($filteredArtifacts.Count -eq 0) { Write-Warning "Artifact list contains no valid entries" - exit 1 - } - - Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')" - $artifactSet = [System.Collections.Generic.HashSet[string]]::new($filteredArtifacts, [System.StringComparer]::OrdinalIgnoreCase) - - # Warn about packages missing ArtifactName property - $missingArtifactName = $allPackageProperties | Where-Object { -not $_.PSObject.Properties.Match('ArtifactName') } - foreach ($pkg in $missingArtifactName) { - Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering." } - $allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) } - - if (!$allPackageProperties) + else { - Write-Error "No packages found matching the provided artifact list" - exit 1 + Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')" + $artifactSet = [System.Collections.Generic.HashSet[string]]::new($filteredArtifacts, [System.StringComparer]::OrdinalIgnoreCase) + + # Warn about packages missing ArtifactName property + $missingArtifactName = $allPackageProperties | Where-Object { $_.PSObject.Properties.Name -notcontains 'ArtifactName' } + foreach ($pkg in $missingArtifactName) { + Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering." + } + $allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) } + + if (!$allPackageProperties) + { + Write-Error "No packages found matching the provided artifact list" + exit 1 + } } } From 2f49f85e711ec275932faccc4056ff9e7e533c0d Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 4 Dec 2025 20:07:43 +0000 Subject: [PATCH 4/5] Fixed hashset issue --- eng/common/scripts/Save-Package-Properties.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 69e052697c55..deccaa553c0e 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -149,7 +149,10 @@ if ($artifactList) else { Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')" - $artifactSet = [System.Collections.Generic.HashSet[string]]::new($filteredArtifacts, [System.StringComparer]::OrdinalIgnoreCase) + $artifactSet = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase) + foreach ($artifact in $filteredArtifacts) { + $artifactSet.Add($artifact) | Out-Null + } # Warn about packages missing ArtifactName property $missingArtifactName = $allPackageProperties | Where-Object { $_.PSObject.Properties.Name -notcontains 'ArtifactName' } From 083217234cf0b22712c27e3e39ef118a4cf5d4ae Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 4 Dec 2025 21:16:01 +0000 Subject: [PATCH 5/5] Added artifacts parameter --- .../pipelines/templates/steps/daily-dev-build-variable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 37efd0bd0312..3191a4928a27 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -2,6 +2,7 @@ # is used when this pipeline is going to be generating and publishing daily dev builds. parameters: ServiceDirectory: '' + Artifacts: [] Condition: succeeded() steps: - ${{if ne(parameters.ServiceDirectory, '')}}: @@ -11,6 +12,7 @@ steps: arguments: > -ServiceDirectory ${{parameters.ServiceDirectory}} -OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo + -artifactList @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json | Select-Object -ExpandProperty name) pwsh: true workingDirectory: $(Pipeline.Workspace) displayName: Dump Package properties