fleetlint Policy for a fleet of repositories
v0.5
Getting started

deps/locked-install/dotnet

Installs use the lockfile strictly

Implements deps/locked-install for dotnet.

Severitywarning
Tiers1, 2
Stacksdotnet
Scopeeach
Kindexpr
Sourcelibrary v0.2.0
Selected byfleetlint-recommended@v0.2.0

Requirement

Where packages.lock.json files exist, restore runs in locked mode: --locked-mode on dotnet restore in a recipe or CI step, or RestoreLockedMode set to true (typically conditioned on CI) in a project or Directory.Build.props.

Why

An install that quietly re-resolves builds and tests something other than what the lockfile in git says, and the drift shows up only in production.

Applies when

exists("**/packages.lock.json")

Check

(taskrunner.recipes.filter(t, !t.matches(r'(?i)update|upgrade|lock|bump|renovate')).map(t, taskrunner.recipes[t]).flatten()
    + params.runners.filter(f, file(f)).map(f, lines(f)).flatten()
    + workflows().map(w, steps(w).map(s, s.run.split("\n")).flatten()).flatten())
    .filter(l, !l.matches(params.noise)).exists(l, l.matches(r'\bdotnet\s+(restore|build|test|publish)\b[^;&|]*--locked-mode\b'))
|| (glob("**/*.csproj") + glob("**/*.fsproj") + glob("**/Directory.Build.props") + ["../", "../../", "../../../"].map(d, d + "Directory.Build.props").filter(f, file(f))).exists(f, text(f).matches(r'(?i)<RestoreLockedMode[^>]*>\s*true'))

Parameters

  • noise: ^\s*[@+-]*\s*(\{\{[^}]*\}\}\s*|\$[({][A-Za-z_]+[)}]\s*)?(#|//|echo\b|printf\b)
  • runners: [../Makefile ../justfile ../Justfile ../Taskfile.yml ../Taskfile.yaml ../../Makefile ../../justfile ../../Justfile ../../Taskfile.yml ../../Taskfile.yaml ../../../Makefile ../../../justfile ../../../Justfile ../../../Taskfile.yml ../../../Taskfile.yaml]

Fix

Add <RestoreLockedMode Condition="'$(CI)' == 'true'">true</RestoreLockedMode> to Directory.Build.props.

Agent instruction: Switch the CI and task-runner installs to the package manager’s locked mode; if that fails, regenerate the lockfile in a separate commit rather than relaxing the install.

See: https://fleetlint.org/baseline/#dependencies, https://fleetlint.org/stacks/#net


Generated by fleetlint docs from catalog v0.2.0.