nuget-warden
0.1.2
dotnet tool install --global nuget-warden --version 0.1.2
dotnet new tool-manifest
dotnet tool install --local nuget-warden --version 0.1.2
#tool dotnet:?package=nuget-warden&version=0.1.2
nuke :add-package nuget-warden --version 0.1.2
๐ก๏ธ nuget-warden
nuget-warden is a cross-platform .NET CLI tool that scans your .csproj
files for blocked NuGet packages, helping enforce security, licensing, and versioning policies in your builds.
It supports:
- โ
Direct
PackageReference
detection - โ
NuGet-style version ranges (
>=
,<
,[1.0.0]
, etc.) - โ YAML-based configuration
- โ
Fast execution (no
dotnet restore
required) - โ Easy integration into CI pipelines
- โ
Supports both traditional
<PackageReference>
and centralized<PackageVersion>
viaDirectory.Packages.props
.
๐ฆ Installation
Install as a global tool:
dotnet tool install nuget-warden
Or reference it locally in your repo as a tool if preferred.
๐ Usage
nuget-warden --help
Usage:
nuget-warden [options]
Options:
--config <path> Path to blocked-packages.yaml file [default: blocked-packages.yaml]
--project-dir <path> Root directory to scan [default: current directory]
--mode <direct|central> Scan mode: direct .csproj or central Directory.Packages.props [default: direct]
--help Show help and usage information
Common examples:
# Default behavior (current directory and default config)
nuget-warden
# Scan a subfolder
nuget-warden --project-dir ./src
# Use a custom config file
nuget-warden --config ./configs/security.yaml
๐ง Configuration (blocked-packages.yaml)
Define packages and allowed version ranges using NuGet-style syntax:
packages:
- id: "Moq"
version: "[4.20.0,)" # same as >= 4.20.0
- id: "MassTransit"
version: "[9.0.0,)" # same as >= 9.0.0
You can use any valid NuGet version range syntax.
๐ How It Works
- Scans .csproj files in the specified directory.
- Parses direct <PackageReference> elements.
- Compares each package ID and version against the blocklist.
- Fails the build with helpful messages if blocked packages are found.
Note: It does not scan transitive dependencies โ only top-level ones declared in the project file.
๐ Scan Modes
You can control how nuget-warden scans dependencies using the --mode option:
--mode <direct|central>
direct
(default) โ scans all .csproj
files for direct <PackageReference>
declarations.
central
โ scans a Directory.Packages.props
file (for projects using Central Package Management).
Examples:
# Scan direct references in all .csproj files
nuget-warden --mode direct
# Scan central package versions from Directory.Packages.props
nuget-warden --mode central --project-dir ./src
โ Example Output
๐ Scanning src/MyProject/MyProject.csproj...
โ Blocked: Moq 4.20.1 in 'MyProject.csproj' (matches '>=4.20.0')
โ Blocked: MassTransit 9.1.0 in 'MyProject.csproj' (matches '>=9.0.0')
๐ซ One or more blocked packages found.
๐งช Recommended Usage in CI
Add to your build scripts to enforce dependency policies:
nuget-warden --config ./blocked-packages.yaml --project-dir .
dotnet build
๐ค Contributing
Pull requests are welcome! If you have suggestions for improvements, feel free to open an issue or PR.
๐งพ License
MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last Updated |
---|---|---|
0.1.2 | 205 | 4/14/2025 |
0.1.2-preview.2 | 163 | 4/14/2025 |
0.1.2-preview.1 | 141 | 4/9/2025 |
0.1.1 | 361 | 4/7/2025 |
0.1.1-preview.1 | 139 | 4/7/2025 |