Skip to content

Commit f71ca00

Browse files
CopilotMiYanni
andcommitted
Revert commit 7bd19ab - Add error handling for vs requirements
Co-authored-by: MiYanni <17788297+MiYanni@users.noreply.github.com>
1 parent bce81fa commit f71ca00

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

eng/common/tools.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,19 +560,25 @@ function LocateVisualStudio([object]$vsRequirements = $null){
560560
})
561561
}
562562

563-
if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
563+
if (!$vsRequirements) {
564+
if (Get-Member -InputObject $GlobalJson.tools -Name 'vs' -ErrorAction SilentlyContinue) {
565+
$vsRequirements = $GlobalJson.tools.vs
566+
} else {
567+
$vsRequirements = $null
568+
}
569+
}
564570
$args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*')
565571

566572
if (!$excludePrereleaseVS) {
567573
$args += '-prerelease'
568574
}
569575

570-
if (Get-Member -InputObject $vsRequirements -Name 'version') {
576+
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'version' -ErrorAction SilentlyContinue)) {
571577
$args += '-version'
572578
$args += $vsRequirements.version
573579
}
574580

575-
if (Get-Member -InputObject $vsRequirements -Name 'components') {
581+
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'components' -ErrorAction SilentlyContinue)) {
576582
foreach ($component in $vsRequirements.components) {
577583
$args += '-requires'
578584
$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

Comments
 (0)