Skip to content

Commit 566eb9e

Browse files
Package Properties processing updates (#40183)
Co-authored-by: James Suplizio <[email protected]>
1 parent d5c7cd8 commit 566eb9e

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

eng/common/scripts/Package-Properties.ps1

+19-7
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class PackageProps {
2626
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
2727
}
2828

29-
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "") {
30-
$this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group)
29+
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "", [string]$artifactName = "") {
30+
$this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group, $artifactName)
3131
}
3232

3333
hidden [void]Initialize(
@@ -70,20 +70,32 @@ class PackageProps {
7070
[string]$version,
7171
[string]$directoryPath,
7272
[string]$serviceDirectory,
73-
[string]$group
73+
[string]$group,
74+
[string]$artifactName
7475
) {
75-
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
7676
$this.Group = $group
77+
$this.ArtifactName = $artifactName
78+
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
7779
}
78-
7980
hidden [PSCustomObject]ParseYmlForArtifact([string]$ymlPath) {
8081
$content = LoadFrom-Yaml $ymlPath
8182
if ($content) {
8283
$artifacts = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "Artifacts")
8384
$artifactForCurrentPackage = $null
84-
8585
if ($artifacts) {
86-
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -or $_["name"] -eq $this.Name }
86+
# If there's an artifactName match that to the name field from the yml
87+
if ($this.ArtifactName) {
88+
# Additionally, if there's a group, then the group and artifactName need to match the groupId and name in the yml
89+
if ($this.Group) {
90+
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -and $_["groupId"] -eq $this.Group}
91+
} else {
92+
# just matching the artifactName
93+
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName }
94+
}
95+
} else {
96+
# This is the default, match the Name to the name field from the yml
97+
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.Name }
98+
}
8799
}
88100

89101
# if we found an artifact for the current package, we should count this ci file as the source of the matrix for this package

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,17 @@ foreach ($pkg in $allPackageProperties)
141141
Write-Host "Package Version: $($pkg.Version)"
142142
Write-Host "Package SDK Type: $($pkg.SdkType)"
143143
Write-Host "Artifact Name: $($pkg.ArtifactName)"
144+
if (-not [System.String]::IsNullOrEmpty($pkg.Group)) {
145+
Write-Host "GroupId: $($pkg.Group)"
146+
}
144147
Write-Host "Release date: $($pkg.ReleaseStatus)"
145148
$configFilePrefix = $pkg.Name
146149

147-
if ($pkg.ArtifactName)
148-
{
149-
$configFilePrefix = $pkg.ArtifactName
150+
# Any languages (like JS) which need to override the the packageInfo file name to be something
151+
# other than the name just need to declare this function in their Language-Settings.ps1 return
152+
# the desired string from there.
153+
if (Test-Path "Function:Get-PackageInfoNameOverride") {
154+
$configFilePrefix = Get-PackageInfoNameOverride $pkg
150155
}
151156

152157
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"

0 commit comments

Comments
 (0)