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 <yuleng@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
moooyo
2026-08-12 15:37:52 +08:00
committed by GitHub
parent b605fd35c5
commit 9e1c39def7
3 changed files with 36 additions and 24 deletions

View File

@@ -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

View File

@@ -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