diff --git a/eng/common/scripts/Update-DocsMsToc.ps1 b/eng/common/scripts/Update-DocsMsToc.ps1 index 7747b77cb106c..97299656ffb38 100644 --- a/eng/common/scripts/Update-DocsMsToc.ps1 +++ b/eng/common/scripts/Update-DocsMsToc.ps1 @@ -140,23 +140,26 @@ for ($i = 0; $i -lt $metadata.Count; $i++) { Write-Host "File metadata already added for $($metadata[$i].Package). Keeping the first entry found." continue } - - Add-Member ` - -InputObject $metadata[$i] ` - -MemberType NoteProperty ` - -Name FileMetadata ` - -Value $fileEntry + if (!($metadata[$i].PSObject.Members.Name -contains "GroupId") -or ($fileEntry.Group -eq $metadata[$i].GroupId)) { + Add-Member ` + -InputObject $metadata[$i] ` + -MemberType NoteProperty ` + -Name FileMetadata ` + -Value $fileEntry + } } } } $packagesForToc = @{} -foreach ($metadataEntry in (GetPackageLookup $metadata).Values) { +$allPackages = GetPackageLookup $metadata +foreach ($metadataKey in $allPackages.Keys) { + $metadataEntry = $allPackages[$metadataKey] if (!$metadataEntry.ServiceName) { - LogWarning "Empty ServiceName for package `"$($metadataEntry.Package)`". Skipping." + LogWarning "Empty ServiceName for package `"$metadataKey`". Skipping." continue } - $packagesForToc[$metadataEntry.Package] = $metadataEntry + $packagesForToc[$metadataKey] = $metadataEntry } # Get unique service names and sort alphabetically to act as the service nodes @@ -183,7 +186,7 @@ foreach ($service in $serviceNameList) { # Client packages get individual entries $clientPackages = $packagesForToc.Values.Where({ $_.ServiceName -eq $service -and ('client' -eq $_.Type) }) - $clientPackages = $clientPackages | Sort-Object -Property Package + $clientPackages = $clientPackages | Sort-Object 'Package', 'GroupId' | Get-Unique if ($clientPackages) { foreach ($clientPackage in $clientPackages) { $packageItems += GetClientPackageNode -clientPackage $clientPackage