.NET SDK is pinned
dotnet/sdk-pinned@v1
global.json names the SDK the build uses and holds it there, rather than letting a newer one on the runner take over.
| Id | dotnet/sdk-pinned |
| Version | v1 |
| Category | dotnet |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | dotnet |
Collectors
This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.
| Collector | Gathers | Inputs it is given |
|---|---|---|
dotnet | The .NET build in the project directory: the SDK it pins, every project file and the frameworks each targets, the packages they reference and which of them are pinned or supplied centrally, and the lock files beside them. | projectDir |
The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.
Configuration
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "dotnet/sdk-pinned@v1",
"severity": "warning",
"with": {
"projectDir": "."
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
How to fix
Pin the SDK in a global.json at the root of the checkout, and stop it rolling forward:
{
"sdk": {
"version": "8.0.204",
"rollForward": "disable"
}
}A rollForward policy other than disable lets any newer SDK the runner carries take the build, so global.json on its own is not a pin. Without the pin an MSBuild or compiler change arrives with the runner image rather than with a commit somebody reviewed.
More in dotnet
dotnet/central-package-management. OneDirectory.Packages.propsdecides the version of every package, rather than each project file deciding its own.dotnet/dependencies-versioned. EveryPackageReferencenames a version itself or takes one from a centralPackageVersion.dotnet/target-framework-floor. Everynet<major>.<minor>framework a project targets is no older than the configured floor.