From 9e1c39def7615290769f10e91f51af9b93e9d4f7 Mon Sep 17 00:00:00 2001 From: moooyo <42196638+moooyo@users.noreply.github.com> Date: Wed, 12 Aug 2026 15:37:52 +0800 Subject: [PATCH] ci: pin .NET 10 SDK to runtime package version (#49835) ## Summary of the Pull Request Pins the .NET 10 SDK used by CI to `10.0.302`, whose `10.0.10` runtime matches the .NET servicing packages declared in `Directory.Packages.props`. This prevents dependency-audit failures caused by the floating `10.0` SDK channel advancing independently of the repository's package versions. ## PR Checklist - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [x] **Tests:** N/A for this pipeline-only configuration change; validation is documented below ## Detailed Description of the Pull Request / Additional comments The CI template previously passed `10.0` to `dotnet-install.ps1 -Channel`. After .NET 10.0.11 became the latest release, CI combined SDK-provided 10.0.11 runtime assets with NuGet runtime assets pinned to 10.0.10. `.pipelines/verifyDepsJsonLibraryVersions.ps1` consequently detected different `System.Private.Windows.GdiPlus.dll` file versions across generated `.deps.json` files. This PR: - Adds the optional `exactVersion` parameter to `.pipelines/v2/templates/steps-ensure-dotnet-version.yml`. Existing callers continue using channel-based installation when the parameter is omitted. - Sets `exactVersion` to `10.0.302` in `.pipelines/v2/templates/job-build-project.yml`; that SDK contains the 10.0.10 runtime. - Defines `DotNetRuntimePackageVersion` once in `Directory.Packages.props` and references it from all 23 .NET servicing packages. - Adds cross-referenced comments so future SDK and runtime package servicing updates remain aligned. ## Validation Steps Performed - Confirmed the centralization assertion failed before the change with 23 literal `10.0.10` package versions and passed afterward with 23 `$(DotNetRuntimePackageVersion)` references and no remaining literals. - Restored `PowerToys.slnx` successfully using `tools/build/build.ps1 -RestoreOnly`. - Ran `dotnet-install.ps1 -Version 10.0.302 -DryRun` and confirmed that it resolves the exact `10.0.302` SDK payload. - Parsed `Directory.Packages.props` successfully as XML. - Ran `git diff --check` successfully. - Azure Pipelines validation remains pending while this PR is in Draft. --------- Co-authored-by: Yu Leng Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .pipelines/v2/templates/job-build-project.yml | 2 + .../templates/steps-ensure-dotnet-version.yml | 10 +++- Directory.Packages.props | 48 ++++++++++--------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.pipelines/v2/templates/job-build-project.yml b/.pipelines/v2/templates/job-build-project.yml index 899a663af2..17680d3024 100644 --- a/.pipelines/v2/templates/job-build-project.yml +++ b/.pipelines/v2/templates/job-build-project.yml @@ -213,6 +213,8 @@ jobs: parameters: sdk: true version: '10.0' + # SDK 10.0.302 contains runtime 10.0.10. Keep this aligned with DotNetRuntimePackageVersion in Directory.Packages.props. + exactVersion: '10.0.302' - ${{ if eq(parameters.runTests, true) }}: - task: VisualStudioTestPlatformInstaller@1 diff --git a/.pipelines/v2/templates/steps-ensure-dotnet-version.yml b/.pipelines/v2/templates/steps-ensure-dotnet-version.yml index 511af33773..5e50ecf8f1 100644 --- a/.pipelines/v2/templates/steps-ensure-dotnet-version.yml +++ b/.pipelines/v2/templates/steps-ensure-dotnet-version.yml @@ -2,6 +2,9 @@ parameters: - name: version type: string default: "10.0" +- name: exactVersion + type: string + default: "" - name: sdk type: boolean default: false @@ -21,7 +24,12 @@ steps: exit 1 } $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" - & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT + $EXACT_VERSION = "${{parameters.exactVersion}}" + if ([string]::IsNullOrWhiteSpace($EXACT_VERSION)) { + & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT + } else { + & ./dotnet-install.ps1 -Version $EXACT_VERSION -InstallDir $NEW_DOTNET_ROOT + } Write-Host "##vso[task.setvariable variable=DOTNET_ROOT]${NEW_DOTNET_ROOT}" Write-Host "##vso[task.prependpath]${NEW_DOTNET_ROOT}" Remove-Item dotnet-install.ps1 -ErrorAction:Ignore diff --git a/Directory.Packages.props b/Directory.Packages.props index 2dd2a190ab..0dd306b407 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,6 +3,8 @@ true true 3.8.3 + + 10.0.10 @@ -41,21 +43,21 @@ - + - + - - - - - - - + + + + + + + @@ -66,9 +68,9 @@ - + - + - + - - - + + + - + - + - + - + - - - - + + + +