@@ -296,7 +296,7 @@ function InstallDotNet([string] $dotnetRoot,
296296 if ($runtime -eq " aspnetcore" ) { $runtimePath = $runtimePath + " \Microsoft.AspNetCore.App" }
297297 if ($runtime -eq " windowsdesktop" ) { $runtimePath = $runtimePath + " \Microsoft.WindowsDesktop.App" }
298298 $runtimePath = $runtimePath + " \" + $version
299-
299+
300300 $dotnetVersionLabel = " runtime toolset '$runtime /$architecture v$version '"
301301
302302 if (Test-Path $runtimePath ) {
@@ -545,19 +545,25 @@ function LocateVisualStudio([object]$vsRequirements = $null){
545545 })
546546 }
547547
548- if (! $vsRequirements ) { $vsRequirements = $GlobalJson.tools.vs }
548+ if (! $vsRequirements ) {
549+ if (Get-Member - InputObject $GlobalJson.tools - Name ' vs' - ErrorAction SilentlyContinue) {
550+ $vsRequirements = $GlobalJson.tools.vs
551+ } else {
552+ $vsRequirements = $null
553+ }
554+ }
549555 $args = @ (' -latest' , ' -format' , ' json' , ' -requires' , ' Microsoft.Component.MSBuild' , ' -products' , ' *' )
550556
551557 if (! $excludePrereleaseVS ) {
552558 $args += ' -prerelease'
553559 }
554560
555- if (Get-Member - InputObject $vsRequirements - Name ' version' ) {
561+ if ($vsRequirements -and ( Get-Member - InputObject $vsRequirements - Name ' version' - ErrorAction SilentlyContinue) ) {
556562 $args += ' -version'
557563 $args += $vsRequirements.version
558564 }
559565
560- if (Get-Member - InputObject $vsRequirements - Name ' components' ) {
566+ if ($vsRequirements -and ( Get-Member - InputObject $vsRequirements - Name ' components' - ErrorAction SilentlyContinue) ) {
561567 foreach ($component in $vsRequirements.components ) {
562568 $args += ' -requires'
563569 $args += $component
@@ -954,4 +960,4 @@ function Enable-Nuget-EnhancedRetry() {
954960 Write-PipelineSetVariable - Name ' NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS' - Value ' 1000'
955961 Write-PipelineSetVariable - Name ' NUGET_RETRY_HTTP_429' - Value ' true'
956962 }
957- }
963+ }
0 commit comments