@@ -206,9 +206,9 @@ function Start-ScriptAnalyzerBuild
206
206
Push-Location $projectRoot / Rules
207
207
Write-Progress " Building ScriptAnalyzer for PSVersion '$PSVersion ' using framework '$framework ' and configuration '$Configuration '"
208
208
if ( -not $script :DotnetExe ) {
209
- $script :dotnetExe = Get-DotnetExe
209
+ $script :DotnetExe = Get-DotnetExe
210
210
}
211
- $buildOutput = & $script :dotnetExe build -- framework $framework -- configuration " $config "
211
+ $buildOutput = & $script :DotnetExe build -- framework $framework -- configuration " $config "
212
212
if ( $LASTEXITCODE -ne 0 ) { throw " $buildOutput " }
213
213
}
214
214
catch {
@@ -442,18 +442,18 @@ function Get-InstalledCLIVersion {
442
442
try {
443
443
# earlier versions of dotnet do not support --list-sdks, so we'll check the output
444
444
# and use dotnet --version as a fallback
445
- $sdkList = & $script :dotnetExe -- list- sdks 2>&1
445
+ $sdkList = & $script :DotnetExe -- list- sdks 2>&1
446
446
$sdkList = " Unknown option"
447
447
if ( $sdkList -match " Unknown option" ) {
448
- $installedVersions = & $script :dotnetExe -- version
448
+ $installedVersions = & $script :DotnetExe -- version
449
449
}
450
450
else {
451
451
$installedVersions = $sdkList | Foreach-Object { $_.Split ()[0 ] }
452
452
}
453
453
}
454
454
catch {
455
455
Write-Verbose - Verbose " $_ "
456
- $installedVersions = & $script :dotnetExe -- version
456
+ $installedVersions = & $script :DotnetExe -- version
457
457
}
458
458
return (ConvertTo-PortableVersion $installedVersions )
459
459
}
@@ -501,30 +501,30 @@ function Get-DotnetExe
501
501
{
502
502
$discoveredDotNet = Get-Command - CommandType Application dotnet - ErrorAction SilentlyContinue
503
503
if ( $discoveredDotNet ) {
504
- $dotnetFoundPath = $discoveredDotNet | Select-Object - First 1 | Foreach-Object { $_.Source }
505
504
Write-Verbose - Verbose " Found dotnet here: $dotnetFoundPath "
506
- $script :DotnetExe = $dotnetFoundPath
507
- return $dotnetFoundPath
505
+ $script :DotnetExe = $discoveredDotNet
506
+ return $discoveredDotNet
508
507
}
509
508
# it's not in the path, try harder to find it
510
509
# check the usual places
511
510
if ( ! (test-path variable:IsWindows) -or $IsWindows ) {
512
511
$dotnetHuntPath = " $HOME \AppData\Local\Microsoft\dotnet\dotnet.exe"
513
- Write-Verbose - Verbose " checking $dotnetHuntPath "
512
+ Write-Verbose - Verbose " checking Windows $dotnetHuntPath "
514
513
if ( test-path $dotnetHuntPath ) {
515
514
$script :DotnetExe = $dotnetHuntPath
516
515
return $dotnetHuntPath
517
516
}
518
517
}
519
518
else {
520
519
$dotnetHuntPath = " $HOME /.dotnet/dotnet"
521
- Write-Verbose - Verbose " checking $dotnetHuntPath "
520
+ Write-Verbose - Verbose " checking non-Windows $dotnetHuntPath "
522
521
if ( test-path $dotnetHuntPath ) {
523
522
$script :DotnetExe = $dotnetHuntPath
524
523
return $dotnetHuntPath
525
524
}
526
525
}
526
+
527
527
Write-Warning " Could not find dotnet executable"
528
528
return [String ]::Empty
529
529
}
530
- $script :dotnetExe = Get-DotnetExe
530
+ $script :DotnetExe = Get-DotnetExe
0 commit comments