Skip to content

Commit e3752cc

Browse files
committed
fine tune messages emitted during the hunt for dotnet
1 parent 34835b8 commit e3752cc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: build.psm1

+11-11
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ function Start-ScriptAnalyzerBuild
206206
Push-Location $projectRoot/Rules
207207
Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'"
208208
if ( -not $script:DotnetExe ) {
209-
$script:dotnetExe = Get-DotnetExe
209+
$script:DotnetExe = Get-DotnetExe
210210
}
211-
$buildOutput = & $script:dotnetExe build --framework $framework --configuration "$config"
211+
$buildOutput = & $script:DotnetExe build --framework $framework --configuration "$config"
212212
if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" }
213213
}
214214
catch {
@@ -442,18 +442,18 @@ function Get-InstalledCLIVersion {
442442
try {
443443
# earlier versions of dotnet do not support --list-sdks, so we'll check the output
444444
# and use dotnet --version as a fallback
445-
$sdkList = & $script:dotnetExe --list-sdks 2>&1
445+
$sdkList = & $script:DotnetExe --list-sdks 2>&1
446446
$sdkList = "Unknown option"
447447
if ( $sdkList -match "Unknown option" ) {
448-
$installedVersions = & $script:dotnetExe --version
448+
$installedVersions = & $script:DotnetExe --version
449449
}
450450
else {
451451
$installedVersions = $sdkList | Foreach-Object { $_.Split()[0] }
452452
}
453453
}
454454
catch {
455455
Write-Verbose -Verbose "$_"
456-
$installedVersions = & $script:dotnetExe --version
456+
$installedVersions = & $script:DotnetExe --version
457457
}
458458
return (ConvertTo-PortableVersion $installedVersions)
459459
}
@@ -501,30 +501,30 @@ function Get-DotnetExe
501501
{
502502
$discoveredDotNet = Get-Command -CommandType Application dotnet -ErrorAction SilentlyContinue
503503
if ( $discoveredDotNet ) {
504-
$dotnetFoundPath = $discoveredDotNet | Select-Object -First 1 | Foreach-Object { $_.Source }
505504
Write-Verbose -Verbose "Found dotnet here: $dotnetFoundPath"
506-
$script:DotnetExe = $dotnetFoundPath
507-
return $dotnetFoundPath
505+
$script:DotnetExe = $discoveredDotNet
506+
return $discoveredDotNet
508507
}
509508
# it's not in the path, try harder to find it
510509
# check the usual places
511510
if ( ! (test-path variable:IsWindows) -or $IsWindows ) {
512511
$dotnetHuntPath = "$HOME\AppData\Local\Microsoft\dotnet\dotnet.exe"
513-
Write-Verbose -Verbose "checking $dotnetHuntPath"
512+
Write-Verbose -Verbose "checking Windows $dotnetHuntPath"
514513
if ( test-path $dotnetHuntPath ) {
515514
$script:DotnetExe = $dotnetHuntPath
516515
return $dotnetHuntPath
517516
}
518517
}
519518
else {
520519
$dotnetHuntPath = "$HOME/.dotnet/dotnet"
521-
Write-Verbose -Verbose "checking $dotnetHuntPath"
520+
Write-Verbose -Verbose "checking non-Windows $dotnetHuntPath"
522521
if ( test-path $dotnetHuntPath ) {
523522
$script:DotnetExe = $dotnetHuntPath
524523
return $dotnetHuntPath
525524
}
526525
}
526+
527527
Write-Warning "Could not find dotnet executable"
528528
return [String]::Empty
529529
}
530-
$script:dotnetExe = Get-DotnetExe
530+
$script:DotnetExe = Get-DotnetExe

0 commit comments

Comments
 (0)