From 75d76dfedfeceb5e448db80c98593e0b01e36bd1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 25 Nov 2026 11:10:42 -0800 Subject: [PATCH] Remove SDKs newer than global.json before running uno-check uno-check installs workloads with the newest SDK it finds, while the build uses the SDK pinned in global.json. Since the runner images ship .NET 11, workloads were being installed into the wrong feature band. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/build.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdc07552..6cef46df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,6 +132,19 @@ jobs: - name: Restore dotnet tools run: dotnet tool restore + # uno-check installs workloads with the newest SDK it finds, ignoring global.json, while the build + # uses the SDK pinned in global.json. The runner images ship a newer SDK too (.NET 11), so the + # workloads would land in the wrong feature band. Remove SDKs newer than the pinned one first. + - name: Remove .NET SDKs newer than global.json + if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linuxgtk' && matrix.multitarget != 'wpf' }} + shell: pwsh + run: | + $pinnedMajor = ([version](Get-Content global.json -Raw | ConvertFrom-Json).sdk.version.Split('-')[0]).Major + Get-ChildItem "$env:ProgramFiles\dotnet\sdk" -Directory | + Where-Object { $_.Name -match '^\d+\.' -and [int]($_.Name.Split('.')[0]) -gt $pinnedMajor } | + ForEach-Object { Write-Host "Removing $($_.FullName)"; Remove-Item $_.FullName -Recurse -Force } + dotnet --list-sdks + - name: Run Uno Check to Install Dependencies if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linuxgtk' && matrix.multitarget != 'wpf' }} run: > @@ -272,6 +285,16 @@ jobs: - name: Restore dotnet tools run: dotnet tool restore + # See the comment in the build job: keep uno-check from using a newer SDK than the one in global.json. + - name: Remove .NET SDKs newer than global.json + shell: pwsh + run: | + $pinnedMajor = ([version](Get-Content global.json -Raw | ConvertFrom-Json).sdk.version.Split('-')[0]).Major + Get-ChildItem "$env:ProgramFiles\dotnet\sdk" -Directory | + Where-Object { $_.Name -match '^\d+\.' -and [int]($_.Name.Split('.')[0]) -gt $pinnedMajor } | + ForEach-Object { Write-Host "Removing $($_.FullName)"; Remove-Item $_.FullName -Recurse -Force } + dotnet --list-sdks + - name: Run Uno Check to Install Dependencies run: > dotnet tool run uno-check