Target framework is no older than the floor
dotnet/target-framework-floor@v1
Every net<major>.<minor> framework a project targets is no older than the configured floor.
| Id | dotnet/target-framework-floor |
| 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/target-framework-floor@v1",
"severity": "warning",
"with": {
"projectDir": ".",
"minFramework": "net8.0"
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
minFramework | Oldest net<major>.<minor> target framework accepted. A project targeting one below this is a violation. | net8.0 | GUARDRAIL_INPUT_MINFRAMEWORK |
How to fix
Retarget the project and rebuild against the newer framework:
<TargetFramework>net8.0</TargetFramework>A framework past the end of its support window stops receiving security fixes, so a build left on it keeps shipping a runtime nobody is patching. netstandard2.0, net48 and netcoreapp3.1 are a different versioning line and are left alone rather than compared with the floor.
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/sdk-pinned.global.jsonnames the SDK the build uses and holds it there, rather than letting a newer one on the runner take over.