Package references carry a version
dotnet/dependencies-versioned@v1
Every PackageReference names its own version or takes one from a central PackageVersion.
| Id | dotnet/dependencies-versioned |
| Version | v1 |
| Category | dotnet |
| Default severity | error |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | dotnet |
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.
| 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 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
{
"guardrails": {
"failOn": "error",
"checks": [
{
"use": "dotnet/dependencies-versioned@v1",
"severity": "error",
"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
Give the reference a version, or add a central PackageVersion for it to take one from:
<PackageReference Include="Serilog" Version="4.0.0" /><PackageVersion Include="Serilog" Version="4.0.0" />A PackageReference with no version of its own and no central one restores whatever NuGet picks, so the package the build compiles against is chosen at restore time, not in the commit.
More in dotnet
dotnet/central-package-management. A singleDirectory.Packages.propssets the version of every package, instead of each project file setting its own.dotnet/sdk-pinned.global.jsonnames the SDK the build uses and holds it there, so a newer SDK on the runner can't take over.dotnet/target-framework-floor. Everynet<major>.<minor>framework a project targets is no older than the configured floor.