Skip to content

Commit b408594

Browse files
Update .NET dependency update script to include test csproj files (PowerShell#12372)
1 parent ba53621 commit b408594

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

tools/UpdateDotnetRuntime.ps1

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,27 @@ function Update-PackageVersion {
4545
"Microsoft.NETCore.Windows.ApiSets"
4646
)
4747

48-
$packages = [System.Collections.Generic.Dictionary[[string], [PkgVer]]]::new()
48+
$packages = [System.Collections.Generic.Dictionary[[string], [PkgVer[]] ]]::new()
4949

50-
Get-ChildItem -Path "$PSScriptRoot/../src/" -Recurse -Filter "*.csproj" -Exclude 'PSGalleryModules.csproj' | ForEach-Object {
50+
$paths = @(
51+
"$PSScriptRoot/packaging/projects/reference/Microsoft.PowerShell.Commands.Utility/Microsoft.PowerShell.Commands.Utility.csproj"
52+
"$PSScriptRoot/packaging/projects/reference/System.Management.Automation/System.Management.Automation.csproj"
53+
"$PSScriptRoot/../src/"
54+
"$PSScriptRoot/../test/tools/"
55+
)
56+
57+
Get-ChildItem -Path $paths -Recurse -Filter "*.csproj" -Exclude 'PSGalleryModules.csproj','PSGalleryTestModules.csproj' | ForEach-Object {
58+
Write-Verbose -Message "Reading - $($_.FullName)" -Verbose
5159
$prj = [xml] (Get-Content $_.FullName -Raw)
5260
$pkgRef = $prj.Project.ItemGroup.PackageReference
5361

5462
foreach ($p in $pkgRef) {
5563
if ($null -ne $p -and -not $skipModules.Contains($p.Include)) {
5664
if (-not $packages.ContainsKey($p.Include)) {
57-
$packages.Add($p.Include, [PkgVer]::new($p.Include, $p.Version, $null, $_.FullName))
65+
$packages.Add($p.Include, @([PkgVer]::new($p.Include, $p.Version, $null, $_.FullName)))
66+
}
67+
else {
68+
$packages[$p.Include] += [PkgVer]::new($p.Include, $p.Version, $null, $_.FullName)
5869
}
5970
}
6071
}
@@ -65,19 +76,22 @@ function Update-PackageVersion {
6576
$packages.GetEnumerator() | ForEach-Object {
6677
$pkgs = Find-Package -Name $_.Key -AllVersions -AllowPreReleaseVersions -Source 'dotnet5'
6778

68-
$version = $_.Value.Version
79+
foreach ($v in $_.Value) {
80+
$version = $v.Version
6981

70-
foreach ($p in $pkgs) {
71-
if ($p.Version -like "$versionPattern*") {
72-
if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) {
73-
$_.Value.NewVersion = $p.Version
74-
break
82+
foreach ($p in $pkgs) {
83+
if ($p.Version -like "$versionPattern*") {
84+
if ([System.Management.Automation.SemanticVersion] ($version) -lt [System.Management.Automation.SemanticVersion] ($p.Version)) {
85+
$v.NewVersion = $p.Version
86+
break
87+
}
7588
}
7689
}
7790
}
7891
}
7992

80-
$pkgsByPath = $packages.Values | Group-Object -Property Path
93+
# we need a ForEach-Object below to unravel each of the items in 'Values' which is an array of PkgVer
94+
$pkgsByPath = $packages.Values | ForEach-Object { $_ } | Group-Object -Property Path
8195

8296
$pkgsByPath | ForEach-Object {
8397
Update-CsprojFile -Path $_.Name -Values $_.Group

0 commit comments

Comments
 (0)