Skip to content

Guardrails / dotnet

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.

Iddotnet/target-framework-floor
Versionv1
Categorydotnet
Default severitywarning
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsdotnet

Collectors ​

This guardrail doesn't gather anything itself. It relies on the collectors below, which the CLI runs once per build before any check, and reads what they found from GUARDRAIL_FACTS. If a collector collects nothing, this guardrail is skipped, not failed.

CollectorGathersInputs it is given
dotnetThe .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 inputs, passed straight through to the collector. Setting one in buildnote.json changes what is collected, and two guardrails configured the same way share a single collection.

Configuration ​

json
{
  "guardrails": {
      "failOn": "error",
      "checks": [
          {
              "use": "dotnet/target-framework-floor@v1",
              "severity": "warning",
              "with": {
                  "projectDir": ".",
                  "minFramework": "net8.0"
              },
              "exemptions": []
          }
      ]
  }
}

Inputs ​

InputDescriptionDefaultEnvironment variable
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR
minFrameworkOldest net<major>.<minor> target framework accepted. A project targeting one below this is a violation.net8.0GUARDRAIL_INPUT_MINFRAMEWORK

How to fix ​

Retarget the project and rebuild it against the newer framework:

xml
<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 belong to a different versioning line, so they are skipped and never compared with the floor.

More in dotnet ​

All 4 dotnet guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412