Command-line tool
editMeziantou.Framework.NuGetPackageValidation.Tool runs the rules of the library on the packages you give it.
The command reference lists every option of the tool.
Install the tool
Install or update it as a global tool:
dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --globalValidate packages
Pass one or more package paths:
meziantou.validate-nuget-package artifacts/MyLibrary.1.0.0.nupkg artifacts/MyLibrary.Tool.1.0.0.nupkg- The packages are validated in parallel, up to the number of processors.
--max-parallelism 1validates one package at a time. - A path given twice is validated once.
- The tool does not expand wildcards: let your shell do it, for instance
artifacts/*.nupkg. - A
.snupkgfile next to a package is used to check its symbols.
Read the output
The result is written to the standard output as JSON. The packages are keyed by their full path, in the order of the arguments:
{
"IsValid": false,
"Packages": {
"/home/user/src/artifacts/Debug.1.0.0.nupkg": {
"Errors": [
{
"ErrorCode": 81,
"Message": "Assembly is not optimized",
"HelpText": "Build the package using the Release configuration: 'dotnet pack --configuration Release'. ...",
"FileName": "lib/net6.0/samplelib.dll"
}
],
"IsValid": false
}
}
}- The exit code is
0when every package is valid, and1otherwise. It is also1when the arguments are invalid, such as an unknown rule. --only-report-errorsleaves the valid packages out of the output, which keeps the log of a large build short.- HelpText and FileName are
nullwhen the error has none.
Choose the rules
Without options, the tool applies the default rules. --rules replaces them, and --excluded-rules removes rules. Both take the rule names of NuGetPackageValidationRules, separated by , or ;, and default stands for the default rules:
meziantou.validate-nuget-package MyLibrary.1.0.0.nupkg --rules default,PackageIdAvailableOnNuGetOrgmeziantou.validate-nuget-package MyLibrary.1.0.0.nupkg --excluded-rules ReadmeMustBeSet,TagsMustBeSetThe names are case-sensitive, as written in --help.
Ignore some errors
--excluded-rule-ids ignores error codes without removing their rule, like ExcludedRuleIds in code:
meziantou.validate-nuget-package MyLibrary.1.0.0.nupkg --excluded-rule-ids 52,119Excluding 119 or 120 also skips the download of the source files of the symbols. See Ignore some errors.
Authenticate the requests
The Symbols rule downloads the source files that Source Link points to. For a private GitHub repository, these downloads need a token:
meziantou.validate-nuget-package MyLibrary.1.0.0.nupkg --github-token "$GITHUB_TOKEN"The token is only sent to raw.githubusercontent.com and its subdomains, as a bearer token. Requests to other hosts are sent without it.
Options
| Option | Description |
|---|---|
<package-path>... | The packages to validate (required) |
--rules <rules> | The rules to apply instead of the default rules |
--excluded-rules <rules> | The rules to remove |
--excluded-rule-ids <ids> | The error codes to ignore, separated by , or ; |
--github-token <token> | The token to send to raw.githubusercontent.com |
--only-report-errors | Only write the packages that have errors |
--max-parallelism <n> | The maximum number of packages validated at the same time. Must be greater than 0 |
meziantou.validate-nuget-package --help shows the same list with the names of all the rules.