Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit f2b5b36

Browse files
bwright86alerickson
authored andcommitted
Improves discovery of usable nuget.exe binary (#558)
Includes minimum required version to the checks in Program Files and User AppData Local folders. This prevents issues with outdated nuget.exe binaries in Program Files occluding newer versions in User's AppData folders or locations on the PATH.
1 parent fe8e733 commit f2b5b36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/PowerShellGet/private/functions/Install-NuGetClientBinaries.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ function Install-NuGetClientBinaries
9393
$applocalDataExePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetAppLocalPath -ChildPath $script:NuGetExeName
9494

9595
# Check if NuGet.exe is available under one of the predefined PowerShellGet locations under ProgramData or LocalAppData
96-
if(Microsoft.PowerShell.Management\Test-Path -Path $programDataExePath)
96+
if( (Microsoft.PowerShell.Management\Test-Path -Path $programDataExePath) -and
97+
($programDataExePath | Microsoft.PowerShell.Core\Get-Command).Version -ge $script:NuGetExeMinRequiredVersion )
9798
{
9899
$NugetExePath = $programDataExePath
99100
}
100-
elseif(Microsoft.PowerShell.Management\Test-Path -Path $applocalDataExePath)
101+
elseif( (Microsoft.PowerShell.Management\Test-Path -Path $applocalDataExePath) -and
102+
($applocalDataExePath | Microsoft.PowerShell.Core\Get-Command).Version -ge $script:NuGetExeMinRequiredVersion )
101103
{
102104
$NugetExePath = $applocalDataExePath
103105
}
@@ -344,4 +346,4 @@ function Install-NuGetClientBinaries
344346
-CallerPSCmdlet $CallerPSCmdlet `
345347
-ErrorCategory InvalidOperation
346348
}
347-
}
349+
}

0 commit comments

Comments
 (0)