Introduction
editA NuGet package can build and install, and still be hard to use: no license, no readme, a placeholder description, assemblies built in Debug, or symbols that the debugger cannot find. These problems show up once the package is published, when they are the hardest to fix.
Meziantou.Framework.NuGetPackageValidation opens a .nupkg file and checks it against a set of rules, before you push it. Meziantou.Framework.NuGetPackageValidation.Tool runs the same rules from the command line, so a build pipeline can fail when a package does not follow them.
What you can do with it
- Validate a package from code or from the command line. See Getting started.
- Know what is checked: metadata, icon, license, readme, optimized assemblies, XML documentation, symbols and Source Link. See Rules and Error codes.
- Choose the rules and ignore some errors, use other symbol servers, and authenticate the HTTP requests. See Configuring the validation.
- Write your own rules, for instance to enforce a naming convention. See Custom rules.
- Validate packages in a build pipeline with the command-line tool. See Command-line tool and Running in CI.
Principles
- Rules report errors with a number. Each problem has an error code, so you can ignore one problem without turning off the whole rule.
- A problem is a result, not an exception. A missing or unreadable package is reported as an error too.
- Some rules use the network. They check that the project URL answers, download the source files that the symbols point to, and query symbol servers. See Network access.
- The package is read, never modified.
Namespace
The types are in the Meziantou.Framework.NuGetPackageValidation namespace. The package path is a FullPath, from the Meziantou.Framework namespace:
| Type | Contains |
|---|---|
| NuGetPackageValidator | ValidateAsync, which validates a package |
| NuGetPackageValidationRules | The built-in rules, and the Default set |
| NuGetPackageValidationOptions | The rules, the excluded error codes, the symbol servers and the HTTP configuration |
| NuGetPackageValidationResult | IsValid and the Errors |
| NuGetPackageValidationError | The ErrorCode, Message, HelpText and FileName of an error |
| NuGetPackageValidationRule, NuGetPackageValidationContext | The base class and the context of a custom rule |
Next steps
- Getting started: validate your first package.