Skip to content
Prev Previous commit
Revert change to tools.ps1
  • Loading branch information
DonnaChen888 committed Nov 18, 2025
commit 9a8299b9768d2dfaa48a68c98563cf42ce8d0ce5
16 changes: 11 additions & 5 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function InstallDotNet([string] $dotnetRoot,
if ($runtime -eq "aspnetcore") { $runtimePath = $runtimePath + "\Microsoft.AspNetCore.App" }
if ($runtime -eq "windowsdesktop") { $runtimePath = $runtimePath + "\Microsoft.WindowsDesktop.App" }
$runtimePath = $runtimePath + "\" + $version

$dotnetVersionLabel = "runtime toolset '$runtime/$architecture v$version'"

if (Test-Path $runtimePath) {
Expand Down Expand Up @@ -545,19 +545,25 @@ function LocateVisualStudio([object]$vsRequirements = $null){
})
}

if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
if (!$vsRequirements) {
if (Get-Member -InputObject $GlobalJson.tools -Name 'vs' -ErrorAction SilentlyContinue) {
$vsRequirements = $GlobalJson.tools.vs
} else {
$vsRequirements = $null
}
}
$args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*')

if (!$excludePrereleaseVS) {
$args += '-prerelease'
}

if (Get-Member -InputObject $vsRequirements -Name 'version') {
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'version' -ErrorAction SilentlyContinue)) {
$args += '-version'
$args += $vsRequirements.version
}

if (Get-Member -InputObject $vsRequirements -Name 'components') {
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'components' -ErrorAction SilentlyContinue)) {
foreach ($component in $vsRequirements.components) {
$args += '-requires'
$args += $component
Expand Down Expand Up @@ -954,4 +960,4 @@ function Enable-Nuget-EnhancedRetry() {
Write-PipelineSetVariable -Name 'NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS' -Value '1000'
Write-PipelineSetVariable -Name 'NUGET_RETRY_HTTP_429' -Value 'true'
}
}
}