Repository navigation
Use get-dotnetup script aka.ms links - #54606
Conversation
Port the dotnetup-based acquisition scripts: configure-toolset installs the bootstrap SDK from global.json and restore-toolset installs the test shared frameworks, both via dotnetup (downloaded by scripts/get-dotnetup.{sh,ps1}). The dotnet-install script is retained as a fallback. Ignore the downloaded eng/dotnetup/ binary.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
these can be acquired via aka.ms links and this provides a more reusable pattern for others, assuming that those scripts are not checked in as source code. initially from feedback via dotnet#54600 next I will dedupe the code.
…up-script-aka-ms-links
…up-script-aka-ms-links # Conflicts: # eng/configure-toolset.ps1 # eng/configure-toolset.sh # eng/restore-toolset.ps1 # eng/restore-toolset.sh
The earlier merge+revert on this branch left the dnx launch scripts at their pre-dotnet#54472 form, which would have reverted main's dnx simplification. Restore them to match upstream/main so this PR only changes dotnetup acquisition.
There was a problem hiding this comment.
Pull request overview
This PR follows up on #54600 by removing the repo-local get-dotnetup scripts and switching toolset bootstrapping/runtime installation to acquire dotnetup via the public aka.ms get-dotnetup scripts, consolidating common caching/architecture logic into shared eng/ helper files.
Changes:
- Delete
scripts/get-dotnetup.{sh,ps1}and instead download/execute the publicaka.ms/dotnetup/get-dotnetup.{sh,ps1}scripts. - Refactor
eng/configure-toolset.*andeng/restore-toolset.*to use new shared helpers for cache freshness checks and acquisition. - Add
eng/dotnetup-shared.{sh,ps1}to centralize dotnetup acquisition/caching logic.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/get-dotnetup.sh | Removed in favor of public aka.ms acquisition script. |
| scripts/get-dotnetup.ps1 | Removed in favor of public aka.ms acquisition script. |
| eng/dotnetup-shared.sh | New shared Bash helpers for caching + acquiring dotnetup. |
| eng/dotnetup-shared.ps1 | New shared PowerShell helpers for caching + acquiring dotnetup. |
| eng/configure-toolset.sh | Uses shared helpers to acquire dotnetup for bootstrap SDK install. |
| eng/configure-toolset.ps1 | Uses shared helpers to acquire dotnetup for bootstrap SDK install. |
| eng/restore-toolset.sh | Uses shared helpers to acquire dotnetup for test runtime install. |
| eng/restore-toolset.ps1 | Uses shared helpers to acquire dotnetup for test runtime install. |
…cript code mimics the pattern of eng/common but we cannot edit eng/common
- bash: use a portable mktemp template (bare mktemp fails on BSD/macOS) - bash: emit a clear diagnostic when neither curl nor wget is available - ps: add retry/backoff to the installer download (works on Windows PowerShell 5.1) - ps: run the downloaded installer in a child process so its 'exit' cannot kill the build host
dotnetup installs the latest 8.0 patch (channel '8.0') rather than exactly 8.0.0, so 'dotnet exec --fx-version 8.0.0' failed with the runtime missing. Discover the actual installed 8.0.x version from the toolset's shared framework dir instead of hard-coding 8.0.0. Mirrors the fix already in release/dnup.
|
Failure is due to what I believe to be a flakey test: |
Take upstream's more robust version discovery logic that validates version strings and checks directory existence. Co-authored-by: Copilot <[email protected]>
When scripts/get-dotnetup.{sh,ps1} exist in the repo (as on release/dnup),
use them directly instead of downloading from aka.ms. On branches without
those scripts (e.g. main), the existing aka.ms download path is used.
This reduces merge conflicts when code flows between the two branches.
Co-authored-by: Copilot <[email protected]>
| # Prefer the repo-local script when available (e.g. on release/dnup). | ||
| if (Test-Path $localGetter) { | ||
| Write-Host "Using local get-dotnetup.ps1 from '$localGetter'." -ForegroundColor DarkGray | ||
| $psExe = (Get-Process -Id $PID).Path | ||
| if (-not (Test-Path Variable:LASTEXITCODE)) { $global:LASTEXITCODE = 0 } | ||
| & $psExe -NoProfile -ExecutionPolicy Bypass -File $localGetter -InstallDir $DotnetupDir | ||
| if ($LASTEXITCODE -ne 0) { throw "Local get-dotnetup.ps1 exited with code $LASTEXITCODE." } | ||
| return | ||
| } |
There was a problem hiding this comment.
If / when we merge release/dnup into main, then we'd start using the get-dotnetup scripts directly from main. But we probably do want to use the scripts directly from release/dnup when running in that branch. I'm not sure if there's a good way to resolve this.
There was a problem hiding this comment.
That's a great point, I considered this too but I'm deferring the problem until we actually do the merge into main as I don't have a great solution.
Extract the duplicated 4-line subprocess execution pattern (get psExe, reset LASTEXITCODE, invoke script, check exit code) into a reusable Invoke-GetDotnetupScript function. Both the local-getter and the aka.ms-downloaded paths now call this single helper. The .sh version was not consolidated because bash invocation is already a one-liner (bash $script --install-dir $dir) with no setup logic. Co-authored-by: Copilot <[email protected]>
The child PowerShell process spawned by Invoke-GetDotnetupScript writes to stderr, which becomes a terminating error when the parent inherits ErrorActionPreference='Stop' from eng/common/tools.ps1. This caused the Windows AOT build to fail with: ##[error](InitializeToolset) Failed to acquire dotnetup: A positional parameter cannot be found that accepts argument 'get-dotnetup.ps1'. Fix by: 1. Temporarily setting ErrorActionPreference='Continue' around the native command invocation in Invoke-GetDotnetupScript, relying on LASTEXITCODE for error detection instead of stderr-as-error. 2. Adding a fallback for Get-Process path resolution. 3. Making configure-toolset.ps1 fall back gracefully to dotnet-install.ps1 (matching restore-toolset.ps1 behavior) instead of hard-failing the build. Co-authored-by: Copilot <[email protected]>
4a97e60 to
3d69e44
Compare
Following up on #54600, we can use the
aka.mslinks instead of hard coding the script. This avoids duplicated source and provides a more reusable pattern for others, assuming that those scripts are not checked in as source code, which they won't be for most repos.