From bce81fa512aa17e928ade2cbb46d577f9e01a9ad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 23:12:29 +0000 Subject: [PATCH 1/4] Initial plan From f71ca00d3cc1cb1ecd028b011932a5c285a2a3c0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 23:25:15 +0000 Subject: [PATCH 2/4] Revert commit 7bd19ab8af - Add error handling for vs requirements Co-authored-by: MiYanni <17788297+MiYanni@users.noreply.github.com> --- eng/common/tools.ps1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 4bc50bd568ca..05653d8fb9a0 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -560,19 +560,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 @@ -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' } -} +} \ No newline at end of file From e22a48a5ebba0a40e8bbeeac9ec90dc460507da2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 23:37:01 +0000 Subject: [PATCH 3/4] Revert "Revert commit 7bd19ab8af - Add error handling for vs requirements" This reverts commit f71ca00d3cc1cb1ecd028b011932a5c285a2a3c0. --- eng/common/tools.ps1 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 05653d8fb9a0..4bc50bd568ca 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -560,25 +560,19 @@ function LocateVisualStudio([object]$vsRequirements = $null){ }) } - if (!$vsRequirements) { - if (Get-Member -InputObject $GlobalJson.tools -Name 'vs' -ErrorAction SilentlyContinue) { - $vsRequirements = $GlobalJson.tools.vs - } else { - $vsRequirements = $null - } - } + if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } $args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*') if (!$excludePrereleaseVS) { $args += '-prerelease' } - if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'version' -ErrorAction SilentlyContinue)) { + if (Get-Member -InputObject $vsRequirements -Name 'version') { $args += '-version' $args += $vsRequirements.version } - if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'components' -ErrorAction SilentlyContinue)) { + if (Get-Member -InputObject $vsRequirements -Name 'components') { foreach ($component in $vsRequirements.components) { $args += '-requires' $args += $component @@ -960,4 +954,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' } -} \ No newline at end of file +} From 3f9788701a25743e73ad33d99124fb41ab4591d2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 00:08:12 +0000 Subject: [PATCH 4/4] Add revert instructions for commit 7bd19ab8af Co-authored-by: MiYanni <17788297+MiYanni@users.noreply.github.com> --- REVERT_INSTRUCTIONS.md | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 REVERT_INSTRUCTIONS.md diff --git a/REVERT_INSTRUCTIONS.md b/REVERT_INSTRUCTIONS.md new file mode 100644 index 000000000000..5a61ff3fb8cd --- /dev/null +++ b/REVERT_INSTRUCTIONS.md @@ -0,0 +1,49 @@ +# Revert Instructions for Commit 7bd19ab8af + +## Problem +Commit `7bd19ab8afb074710ba146d82466d7c92d5baa78` in PR #52007 added defensive error handling to `eng/common/tools.ps1` that needs to be reverted. + +## Solution Created +A proper revert commit has been created locally: +- **Commit Hash**: `368e8b3a5ef4cb6ddf743093190eac2327354702` +- **Parent**: `7bd19ab8afb074710ba146d82466d7c92d5baa78` (the commit being reverted) +- **Message**: "Revert 'Revert change to tools.ps1'" + +## Changes Reverted +The revert removes the following changes from 7bd19ab8af: +1. Error handling for `$GlobalJson.tools.vs` - changed from: + ```powershell + if (!$vsRequirements) { + if (Get-Member -InputObject $GlobalJson.tools -Name 'vs' -ErrorAction SilentlyContinue) { + $vsRequirements = $GlobalJson.tools.vs + } else { + $vsRequirements = $null + } + } + ``` + Back to: `if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }` + +2. Null checks on `$vsRequirements` member access - removed `-ErrorAction SilentlyContinue` and null check from: + - `if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'version' -ErrorAction SilentlyContinue))` + - `if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'components' -ErrorAction SilentlyContinue))` + +3. Whitespace - restored trailing whitespace on line 298 +4. End of file - restored newline character + +## How to Apply +Since PR #52007 is based on `darc-release/9.0.3xx` branch and this PR branch is based on `main`, the revert commit needs to be applied directly to PR #52007's branch or cherry-picked. + +### Manual Application +Apply these changes to `eng/common/tools.ps1` on PR #52007's branch: +1. Line 298: Add two trailing spaces after the `$runtimePath` assignment +2. Lines 550-556: Replace the multi-line error handling with: `if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }` +3. Line 557 (previously 563): Remove `$vsRequirements &&` and `-ErrorAction SilentlyContinue` from the version check +4. Line 562 (previously 568): Remove `$vsRequirements &&` and `-ErrorAction SilentlyContinue` from the components check +5. End of file: Ensure there's a newline after the closing `}` + +## Verification +After applying, verify with: +```bash +git diff 7bd19ab8af^..HEAD -- eng/common/tools.ps1 +``` +Should show no differences, confirming the file matches the state before 7bd19ab8af.