Skip to content

Conversation

@filzrev
Copy link
Contributor

@filzrev filzrev commented Jan 27, 2026

This PR intended to fix transient error on CI when downloading dotnet-install.ps1/ dotnet-install.sh.

Background
I've recently encountered following errors on CI multiple times.

Exception calling "DownloadFile" with "2" argument(s): "The underlying connection was closed: An unexpected error occur
red on a send."
At C:\a\BenchmarkDotNet\BenchmarkDotNet\build\build.ps1:58 char:5
+     (New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUr ...
Run ./build.cmd install-wasm-tools
bash: /home/runner/work/BenchmarkDotNet/BenchmarkDotNet/.dotnet/dotnet-install.sh: No such file or directory

It seems to be failed to download dotnet-install.ps1/ dotnet-install.sh with temporary network errors.

Currently curl is executed on -Lsfo option so error is silently ignored.
So I've added S option to show failure on script download.

And I've added following setting to reduce transient errors.

--retry 5 --retry-delay 5

On windows environment.
I've also modified to use curl executable instead of Invoke-WebRequest

@filzrev filzrev force-pushed the chore-add-retry-for-curl branch from ce1596f to f87af3f Compare January 28, 2026 08:03
@filzrev
Copy link
Contributor Author

filzrev commented Jan 28, 2026

I've modified scripts to use pwsh command instead of powershell.exe on Windows environment.

By this change, PowerShell Core installation is required to use build.cmd on Windows environment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the CI/local build bootstrap by adding retries to the dotnet-install download and standardizing on PowerShell Core for the Windows build entrypoint.

Changes:

  • Add curl retry options (--retry 5 --retry-delay 5) and -S to surface download failures when fetching dotnet-install.sh and dotnet-install.ps1.
  • Switch the PowerShell build script to run under PowerShell Core (pwsh) with a #Requires -PSEdition Core directive.
  • Update Windows build documentation and build.bat to reflect and use PowerShell Core instead of Windows PowerShell.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
docs/articles/contributing/building.md Updates Windows prerequisites to require PowerShell Core, aligning docs with the new build script behavior.
build/build.sh Uses curl -LsSfo ... --retry 5 --retry-delay 5 to download dotnet-install.sh more robustly before running it.
build/build.ps1 Enforces PowerShell Core, replaces WebClient.DownloadFile with a curl-based download that includes retries and error output.
build/build.bat Changes the Windows launcher to invoke pwsh instead of PowerShell, so the build runs under PowerShell Core.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to 7
#Requires -PSEdition Core

$DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1';
$BuildPath = Split-Path $MyInvocation.MyCommand.Path -Parent
$PSScriptRoot = Split-Path $PSScriptRoot -Parent
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #Requires -PSEdition Core at the top, this script can never run on non-Core PowerShell, so the compatibility block that checks $PSVersionTable.PSEdition -ne 'Core' and configures legacy TLS behavior a few lines below is now effectively dead code; consider removing that block to avoid confusion and keep the script focused on the supported runtime.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the compatibility block that checks $PSVersionTable.PSEdition -ne 'Core' and configures legacy TLS behavior a few lines below is now effectively dead code

I've removed dead code on latest commit (a731881)

@@ -1,2 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" No newline at end of file
pwsh -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" No newline at end of file
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this launcher from PowerShell to pwsh drops support for environments that only have Windows PowerShell 5.x installed, meaning build.cmd will now fail on such machines unless PowerShell Core is installed; please confirm this breaking change in build requirements is intentional, or add a fallback to Windows PowerShell if Core is unavailable.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant