Skip to content

Update-WdkVersion.ps1 now sorts by latest version#5258

Open
nmlud21 wants to merge 1 commit into
microsoft:mainfrom
nmlud21:issue5256
Open

Update-WdkVersion.ps1 now sorts by latest version#5258
nmlud21 wants to merge 1 commit into
microsoft:mainfrom
nmlud21:issue5256

Conversation

@nmlud21
Copy link
Copy Markdown
Contributor

@nmlud21 nmlud21 commented May 11, 2026

Description

Update-WdkVersion.ps1 can potentially select the wrong WDK version when NuGet returns multiple results. The script takes the first result from nuget list, but NuGet does not guarantee output order. This results in the latest version not always being chosen.

This PR fixes this issue by sorting the output by version number to ensure the latest version is selected.

Resolves #5256

Testing

N/A

Documentation

No

Installation

No

Signed-off-by: Nicholas Ludwig <nludwig@microsoft.com>
Copy link
Copy Markdown
Contributor

@mikeagun mikeagun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me other than a (pre-existing) regex issue.

}
$packageLine = $package | Where-Object { $_ -match $packageName }
if (-not $packageLine) {
$packageLines = $package | Where-Object { $_ -match "^$packageName\s+" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$packageName contains dots, which are regex wildcards. This is a pre-existing issue and doesn't seem likely to cause issues here, but using [regex]::Escape($packageName) for each of the -match and -replace patterns would avoid this ambiguity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Update-WdkVersion.ps1 selects wrong WDK version when NuGet returns multiple results

3 participants