Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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, '')}}:
Expand All @@ -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
Expand Down
41 changes: 39 additions & 2 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ 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
with artifact names matching entries in this list will be processed.
#>

[CmdletBinding()]
Expand All @@ -39,7 +43,8 @@ Param (
[Parameter(Mandatory = $True)]
[string] $outDirectory,
[string] $prDiff,
[switch] $addDevVersion
[switch] $addDevVersion,
[array] $artifactList
)

. (Join-Path $PSScriptRoot common.ps1)
Expand Down Expand Up @@ -132,6 +137,38 @@ 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"
}
else
{
Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')"
$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' }
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
}
}
}

foreach ($pkg in $allPackageProperties)
{
if ($pkg.Name)
Expand Down