Skip to content

Use get-dotnetup script aka.ms links - #54606

Merged
nagilson merged 18 commits into
dotnet:mainfrom
nagilson:nagilson-use-dotnetup-script-aka-ms-links
Jun 11, 2026
Merged

nagilson merged 18 commits into
dotnet:mainfrom
nagilson:nagilson-use-dotnetup-script-aka-ms-links

Conversation

@nagilson

@nagilson nagilson commented Jun 4, 2026

Copy link
Copy Markdown
Member

Following up on #54600, we can use the aka.ms links 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.

nagilson and others added 4 commits June 4, 2026 12:20
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.
…e-dotnetup-script-aka-ms-links"

This reverts commit 3191266, reversing
changes made to d151d25.
nagilson added 3 commits June 4, 2026 16:27
…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.
@nagilson
nagilson marked this pull request as ready for review June 4, 2026 23:51
Copilot AI review requested due to automatic review settings June 4, 2026 23:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 public aka.ms/dotnetup/get-dotnetup.{sh,ps1} scripts.
  • Refactor eng/configure-toolset.* and eng/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.

Comment thread eng/dotnetup-shared.sh Resolved
Comment thread eng/dotnetup-shared.sh Resolved
Comment thread eng/dotnetup-shared.ps1 Resolved
nagilson added 4 commits June 4, 2026 16:56
…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.
@nagilson

nagilson commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

Failure is due to what I believe to be a flakey test:

》/datadisks/disk1/work/A718099B/t/dotnetSdkTests.B0XXIfVI/Pack_CustomPath/MyFileBasedTool.cs.csproj : error MSB4025: The project file could not be loaded. Could not find file '/datadisks/disk1/work/A718099B/t/dotnetSdkTests.B0XXIfVI/Pack_CustomPath/MyFileBasedTool.cs.csproj'.
[xUnit.net 00:00:23.64]     Microsoft.DotNet.Cli.Run.Tests.RunFileTests_BuildCommands.Pack_CustomPath [OUTPUT] Command 'dotnet pack MyFileBasedTool.cs' exited with exit code 1.
[xUnit.net 00:00:23.70]     Microsoft.DotNet.Cli.Run.Tests.RunFileTests_BuildCommands.Pack_CustomPath [FAIL]
[xUnit.net 00:00:23.70]       Expected value to be 0 because Expected command to pass but it did not.
[xUnit.net 00:00:23.70]       Working Directory: /datadisks/disk1/work/A718099B/t/dotnetSdkTests.B0XXIfVI/Pack_CustomPath
[xUnit.net 00:00:23.70]       File Name: /datadisks/disk1/work/A718099B/p/d/dotnet
[xUnit.net 00:00:23.70]       Arguments: pack MyFileBasedTool.cs
[xUnit.net 00:00:23.70]       Exit Code: 1
[xUnit.net 00:00:23.85]       StdOut:
[xUnit.net 00:00:23.86]         Determining projects to restore...
[xUnit.net 00:00:23.86]         Restored /datadisks/disk1/work/A718099B/t/dotnetSdkTests.B0XXIfVI/Pack_CustomPath/MyFileBasedTool.cs.csproj (in 268 ms).
[xUnit.net 00:00:23.86]       /datadisks/disk1/work/A718099B/p/d/sdk/11.0.100-ci/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
[xUnit.net 00:00:23.86]         MyFileBasedTool.cs -> /home/helixbot/.local/share/dotnet/runfile/MyFileBasedTool-2220d8f7c435ce8cfa8e5d37d422cf651f0e43da3c356db947b930beca45db96/bin/release/MyFileBasedTool.dll
[xUnit.net 00:00:23.86]       /datadisks/disk1/work/A718099B/t/dotnetSdkTests.B0XXIfVI/Pack_CustomPath/MyFileBasedTool.cs.csproj : error MSB4025: The project file could not be loaded. Could not find file '/datadisks/disk1/work/A718099B/t/dotnetSdkTests.B0XXIfVI/Pack_CustomPath/MyFileBasedTool.cs.csproj'.

nagilson and others added 2 commits June 8, 2026 10:20
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]>
Comment thread eng/dotnetup-shared.ps1
Comment on lines +47 to +55
# 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
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@nagilson nagilson Jun 10, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Comment thread eng/dotnetup-shared.ps1 Resolved
nagilson and others added 2 commits June 10, 2026 09:50
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]>
@nagilson
nagilson force-pushed the nagilson-use-dotnetup-script-aka-ms-links branch from 4a97e60 to 3d69e44 Compare June 10, 2026 21:19
@nagilson
nagilson merged commit 7b0f367 into dotnet:main Jun 11, 2026
21 of 24 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants