Rules
editA rule checks one aspect of a package and reports one or more error codes. The rules are the properties of NuGetPackageValidationRules, and the command-line tool takes the same names.
Default rules
NuGetPackageValidationRules.Default holds the rules that apply to most packages. ValidateAsync and the command-line tool use them when you do not choose the rules.
AssembliesMustBeOptimized
Checks that the .dll and .exe files of the package are built with optimizations, as in the Release configuration. Files that are not .NET assemblies are skipped.
81AssemblyIsNotOptimized: pack withdotnet pack --configuration Release, or setOptimizetotruein the project.
AuthorMustBeSet
Checks the authors metadata.
11AuthorNotSet: set theAuthorsproperty of the project.12DefaultAuthorSet: the authors are the package id, a sign thatAuthorswas not set explicitly.
DescriptionMustBeSet
Checks the description metadata.
42DescriptionNotSet: set theDescriptionproperty of the project.43PackageHasDefaultDescription: the description is thePackage Descriptionplaceholder.44PackageDescriptionIsTooLong: the description is longer than 4,000 characters.41UseDeprecatedSummary: the package uses the deprecatedsummarymetadata.
IconMustBeSet
Checks that the package embeds its icon.
32IconNotSet: the package has no icon. Add an image to the package and set thePackageIconproperty.31UseDeprecatedIconUrl: the package only has the deprecatediconUrlmetadata. A package can have bothiconandiconUrl.33IconNotFound: the icon file is not in the package.35IconFileFormatNotSupported: the icon is neither a.pngnor a.jpgor.jpegfile.36IconFileInvalidExtension: the content of the file does not match its extension, for instance a PNG image namedicon.jpg.34IconFileTooLarge: the icon is larger than 1 MB.
LicenseMustBeSet
Checks that the package declares its license with a license expression or a license file.
21LicenseNotSet: set thePackageLicenseExpressionproperty, or add a file and setPackageLicenseFile.22UseDeprecatedLicenseUrl: the package only has the deprecatedlicenseUrlmetadata.23LicenseFileNotFound: the license file is not in the package.
ProjectUrlMustBeSet
Checks that the package has a project URL and that it answers. It sends a GET request to the project URL, and to the repository URL when the package has one.
51ProjectUrlNotSet: set thePackageProjectUrlproperty.52ProjectUrlNotAccessible: the project URL is not an absolutehttporhttpsURL, or the project or repository URL does not answer with a success status code. A private repository does not answer anonymous requests: exclude this code for such packages.
ReadmeMustBeSet
Checks that the package embeds a readme.
61ReadmeNotSet: add a Markdown file to the package and set thePackageReadmeFileproperty.62ReadmeFileNotFound: the readme file is not in the package.
RepositoryMustBeSet
Checks the repository metadata, which links the package to the source code it was built from.
71RepositoryNotSet: the package has no repository metadata.72RepositoryTypeNotSet,73RepositoryUrlNotSet,74RepositoryCommitNotSet: the repository metadata misses its type, its URL or its commit.
Symbols
Checks that the debugger can find the symbols of each .NET assembly in lib and analyzers, and the source files they point to. Satellite assemblies are skipped. The rule looks for the symbols, in this order:
- a portable PDB embedded in the assembly;
- a
.pdbfile next to the assembly in the package; - a
.pdbfile at the same path in the.snupkgfile next to the package; - the symbol servers.
It then reports:
111SymbolsNotFound: no symbols were found. The message lists the symbol servers that could not be queried.117FullPdb: the symbols are a Windows PDB. SetDebugTypetoportableorembedded.118PdbDoesNotMatchAssembly: the symbols are not the ones of this build of the assembly.114CompilerFlagsNotPresent: the symbols do not record the compiler flags. Build with a .NET SDK 5.0.300 or later.115InvalidCompilerVersion and116CompilerDoesNotSupportReproducibleBuilds: the compiler that built the assembly is not recorded correctly, or is too old for reproducible builds.112NonDeterministic: a source path is a path of the build machine instead of a deterministic/_/path. SetContinuousIntegrationBuildtotrueon the build server.113SourceFileNotAccessible: a source file is neither embedded in the symbols nor mapped to a URL by Source Link.119UrlIsNotAccessible: the URL that Source Link gives for a source file is invalid or does not answer.120FileHashIsNotValid,121FileHashIsNotProvided,122NotSupportedHashAlgorithm: the downloaded source file is not the one the assembly was compiled from, or its hash cannot be checked.
The rule downloads every source file that Source Link maps to a URL. Exclude 119 or 120 to skip these downloads.
TagsMustBeSet
Checks the tags metadata.
131TagsNotSet: set thePackageTagsproperty.132TagsTooLong: the tags are longer than 4,000 characters.
XmlDocumentationMustBePresent
Checks that each .NET library in lib has its XML documentation file (MyLibrary.xml next to MyLibrary.dll), so that IDEs show the documentation of its API. Satellite assemblies and executables are skipped.
101XmlDocumentationNotFound: setGenerateDocumentationFiletotruein the project.
Additional rules
These rules are not in Default: add them explicitly.
PackageIdAvailableOnNuGetOrg
Checks that no package with the same id exists on nuget.org. Use it before the first release of a package.
92PackageIdExistsOnNuGetOrg: the id is taken.91CannotCheckPackageIdExistsOnNuGetOrg: nuget.org could not be queried.
RepositoryBranchMustBeSet
Checks that the repository metadata has a branch.
75RepositoryBranchNotSet: the repository metadata has no branch.