Skip to content

Commit 8a7ea47

Browse files
committed
additional logic for finding dotnet executable
1 parent e3752cc commit 8a7ea47

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

build.psm1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,13 @@ function Receive-DotnetInstallScript
499499

500500
function Get-DotnetExe
501501
{
502-
$discoveredDotNet = Get-Command -CommandType Application dotnet -ErrorAction SilentlyContinue
503-
if ( $discoveredDotNet ) {
504-
Write-Verbose -Verbose "Found dotnet here: $dotnetFoundPath"
505-
$script:DotnetExe = $discoveredDotNet
506-
return $discoveredDotNet
502+
$discoveredDotnet = Get-Command -CommandType Application dotnet -ErrorAction SilentlyContinu
503+
if ( $discoveredDotnet ) {
504+
# it's possible that there are multiples. Take the highest version we find
505+
$latestDotnet = $discoveredDotNet | Sort-object { [version](& $_ --version) } | Select-Object -Last 1
506+
Write-Verbose -Verbose "Found dotnet here: $latestDotnet"
507+
$script:DotnetExe = $latestDotnet
508+
return $latestDotnet
507509
}
508510
# it's not in the path, try harder to find it
509511
# check the usual places

0 commit comments

Comments
 (0)