-
Notifications
You must be signed in to change notification settings - Fork 317
Use global.json to restrict .NET SDK use #3797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 introduces global.json to standardize the .NET SDK version (9.0.0) across the project and migrates pipeline files to use UseDotNet@2 with useGlobalJson: true instead of hardcoded version numbers or the ensure-dotnet-version.yml template. The changes simplify SDK installation, remove unnecessary runtime installations in build-only scenarios, and reduce redundant .NET Framework test targets in the stress tests.
Key changes:
- Added
global.jsonspecifying .NET 9.0 SDK withrollForward: "feature"policy - Updated 6 pipeline files to use
UseDotNet@2withuseGlobalJson: true - Removed installation of .NET 8.x runtime in build-only scenarios where tests aren't run
- Reduced stress test .NET Framework targets from 6 versions to just net462
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 |
|---|---|
| global.json | New file specifying .NET 9.0.0 SDK requirement with feature rollforward and no prerelease versions |
| eng/pipelines/steps/compound-build-akv-step.yml | Migrated from hardcoded SDK/runtime installation to global.json; removed unnecessary .NET 8.x runtime |
| eng/pipelines/stages/stress-tests-ci-stage.yml | Reduced .NET Framework test targets from 6 versions to just net462 |
| eng/pipelines/jobs/stress-tests-ci-job.yml | Updated to use global.json for SDK installation and changed .NET 8 runtime from '8.x' to '8.0' |
| eng/pipelines/dotnet-sqlclient-ci-core.yml | Added net9.0 to x86 test target frameworks with explanatory comments |
| eng/pipelines/common/templates/steps/build-all-configurations-signed-dlls-step.yml | Migrated to global.json; removed unnecessary .NET 8.x runtime installation |
| eng/pipelines/common/templates/jobs/ci-run-tests-job.yml | Simplified x86 SDK/runtime installation using global.json and added .NET 8.0 runtime for tests |
| eng/pipelines/common/templates/jobs/ci-code-coverage-job.yml | Replaced ensure-dotnet-version template with UseDotNet@2 using global.json |
paulmedynski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commentary for reviewers.
| parameters: | ||
| packageType: 'sdk' | ||
| version: '10.0' | ||
| # Install whichever .NET SDKs are specified in our global.json. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage only runs on Windows x64, so we don't need the special ensure-dotnet.version template here.
| packageType: sdk | ||
| version: '9.x' | ||
|
|
||
| - task: UseDotNet@2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a .NET 8 runtime to build things. We would only need it to run tests, which doesn't happen as part of this pipeline tree.
| packageType: 'sdk' | ||
| version: '9.x' | ||
|
|
||
| - task: UseDotNet@2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a .NET 8 runtime to build things. We would only need it to run tests, which doesn't happen as part of this pipeline tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
eng/pipelines/jobs/stress-tests-ci-job.yml:146
- With the stress tests now targeting net9.0 (as specified in netTestRuntimes parameter which defaults to [net8.0, net9.0]), the .NET 9.0 runtime should also be installed. Consider adding:
# Install the .NET 9.0 runtime to run tests that target it.
- task: UseDotNet@2
displayName: Install .NET 9.0 Runtime
inputs:
packageType: runtime
version: 9.x # Install the .NET 8.0 runtime to run tests that target it.
- task: UseDotNet@2
displayName: Install .NET 8.0 Runtime
inputs:
packageType: runtime
version: 8.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 16 comments.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
paulmedynski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commentary for reviewers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a separate PowerShell file for this work has several benefits:
- Easy to test locally.
- IDE syntax highlighting and intellisense.
- Easier to review.
| an empty array. | ||
| .NOTES | ||
| Licensed to the .NET Foundation under one or more agreements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first line in the file needs to be the comment-based help <# #>, so the license needs to go somewhere else. This was Gemini's suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.
897a15a to
d5ce1f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.
…on, currently 9.0. - Using global.json to install .NET SDKs everywhere except when we may need ARM64. - Removed unnecessary installation of .NET SDKs and runtimes where they aren't needed. - Added all target frameworks to the x86 test runs. - Updated documentation related to SDKs. - Removed runtime ARM64 architecture detection in favour of explicit parameters for the test jobs that use ARM64. - Created separate PowerShell script to install .NET for ARM64. - Updated install-dotnet template to handle all cases of .NET SDK and Runtime installation for the pipelines.
- Fixed typo in ARM64 pipeline. - Addressed Copilot suggestions.
d5ce1f0 to
928257c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
| & "$InstallDir/dotnet-install.ps1" -Verbose:$Debug -DryRun:$DryRun @installParams | ||
|
|
||
| #------------------------------------------------------------------------------ | ||
| # Install the Runtimes, if any. | ||
|
|
||
| foreach ($channel in $Runtimes) | ||
| { | ||
| Write-Host "Installing .NET Runtime GA channel: $channel" | ||
|
|
||
| $installParams = | ||
| @{ | ||
| Architecture = "arm64" | ||
| Channel = "$channel" | ||
| InstallDir = "$InstallDir" | ||
| Quality = "GA" | ||
| Runtime = "dotnet" | ||
| } | ||
|
|
||
| if ($Debug) | ||
| { | ||
| Write-Host "dotnet-install.ps1 parameters:" | ||
| Write-Host ($installParams | ConvertTo-Json -Depth 1) | ||
| } | ||
|
|
||
| & "$InstallDir/dotnet-install.ps1" -Verbose:$Debug -DryRun:$DryRun @installParams | ||
| } |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script doesn't set $ErrorActionPreference or use error handling to ensure that failures in the dotnet-install.ps1 script invocations will propagate and fail the pipeline step. If the SDK or runtime installation fails, the script will continue executing and set the environment variables, potentially leading to subsequent steps using an incomplete or missing installation. Consider adding $ErrorActionPreference = 'Stop' at the beginning of the script or checking $LASTEXITCODE after each dotnet-install.ps1 invocation.
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Description
Testing
PR, CI, and Official pipelines will validate.