@@ -202,6 +202,9 @@ function Start-ScriptAnalyzerBuild
202
202
try {
203
203
Push-Location $projectRoot / Rules
204
204
Write-Progress " Building ScriptAnalyzer for PSVersion '$PSVersion ' using framework '$framework ' and configuration '$Configuration '"
205
+ if ( -not $script :DotnetExe ) {
206
+ $script :dotnetExe = Get-DotnetExe
207
+ }
205
208
$buildOutput = & $script :dotnetExe build -- framework $framework -- configuration " $config "
206
209
if ( $LASTEXITCODE -ne 0 ) { throw " $buildOutput " }
207
210
}
@@ -308,6 +311,11 @@ function Install-Dotnet
308
311
If ( $PSCmdlet.ShouldProcess (" $installScriptName for $version " )) {
309
312
& " ${installScriptPath} " - c release - version $version
310
313
}
314
+ # this may be the first time that dotnet has been installed,
315
+ # set up the executable variable
316
+ if ( -not $script :DotnetExe ) {
317
+ $script :DotnetExe = Get-DotnetExe
318
+ }
311
319
}
312
320
catch {
313
321
throw $_
@@ -336,7 +344,10 @@ function ConvertTo-PortableVersion {
336
344
foreach ( $v in $strVersion ) {
337
345
$ver , $pre = $v.split (" -" , 2 )
338
346
try {
339
- [int ]$major , [int ]$minor , [int ]$patch = $ver.Split (" ." )
347
+ [int ]$major , [int ]$minor , [int ]$patch , $unused = $ver.Split (" ." , 4 )
348
+ if ( -not $pre ) {
349
+ $pre = $unused
350
+ }
340
351
}
341
352
catch {
342
353
Write-Warning " Cannot convert '$v ' to portable version"
@@ -420,6 +431,10 @@ function Test-SuitableDotnet {
420
431
421
432
# these are mockable functions for testing
422
433
function Get-InstalledCLIVersion {
434
+ # dotnet might not have been installed _ever_, so just return 0.0.0.0
435
+ if ( -not $script :DotnetExe ) {
436
+ return (ConvertTo-PortableVersion 0.0 .0 )
437
+ }
423
438
try {
424
439
# earlier versions of dotnet do not support --list-sdks, so we'll check the output
425
440
# and use dotnet --version as a fallback
0 commit comments