Meziantou.Framework.NuGetPackageValidation
2.0.17
Prefix Reserved
dotnet add package Meziantou.Framework.NuGetPackageValidation --version 2.0.17
NuGet\Install-Package Meziantou.Framework.NuGetPackageValidation -Version 2.0.17
<PackageReference Include="Meziantou.Framework.NuGetPackageValidation" Version="2.0.17" />
<PackageVersion Include="Meziantou.Framework.NuGetPackageValidation" Version="2.0.17" />
<PackageReference Include="Meziantou.Framework.NuGetPackageValidation" />
paket add Meziantou.Framework.NuGetPackageValidation --version 2.0.17
#r "nuget: Meziantou.Framework.NuGetPackageValidation, 2.0.17"
#:package Meziantou.Framework.NuGetPackageValidation@2.0.17
#addin nuget:?package=Meziantou.Framework.NuGetPackageValidation&version=2.0.17
#tool nuget:?package=Meziantou.Framework.NuGetPackageValidation&version=2.0.17
Meziantou.Framework.NuGetPackageValidation
A .NET library for validating NuGet packages to ensure they follow best practices and contain all required metadata and files.
Usage
This library provides a comprehensive set of validation rules to check NuGet packages (.nupkg) and symbol packages (.snupkg) for common issues, missing metadata, and compliance with NuGet best practices.
Basic Validation
The types are in the Meziantou.Framework.NuGetPackageValidation namespace. The package path is a FullPath, from the Meziantou.Framework namespace.
// Validate a package with default rules
var result = await NuGetPackageValidator.ValidateAsync(FullPath.FromPath("MyPackage.1.0.0.nupkg"));
if (result.IsValid)
{
Console.WriteLine("Package is valid!");
}
else
{
foreach (var error in result.Errors)
{
Console.WriteLine($"{error.ErrorCode}: {error.Message}");
if (error.HelpText is not null)
{
Console.WriteLine($" Help: {error.HelpText}");
}
}
}
Custom Rules
var packagePath = FullPath.FromPath(AppContext.BaseDirectory) / "Packages" / "Release_Author.1.0.0.nupkg";
// Validate with specific rules only
var result = await NuGetPackageValidator.ValidateAsync(
packagePath,
[
NuGetPackageValidationRules.AuthorMustBeSet,
NuGetPackageValidationRules.LicenseMustBeSet,
NuGetPackageValidationRules.IconMustBeSet,
]);
Assert.False(result.IsValid);
Assert.Equal([21, 32], result.Errors.Select(error => error.ErrorCode).Order()); // LicenseNotSet, IconNotSet
Custom Options
Rules are excluded by their numeric error code.
var options = new NuGetPackageValidationOptions();
// Add default rules
foreach (var rule in NuGetPackageValidationRules.Default)
{
options.Rules.Add(rule);
}
// Exclude specific error codes
options.ExcludedRuleIds.Add(32); // IconNotSet
// Configure symbol servers
options.SymbolServers.Clear();
options.SymbolServers.Add("https://msdl.microsoft.com/download/symbols/");
options.SymbolServers.Add("https://symbols.nuget.org/download/symbols/");
// Configure HTTP requests (e.g., add authentication)
options.ConfigureRequest = request =>
{
request.Headers.Add("X-Custom-Header", "value");
};
var result = await NuGetPackageValidator.ValidateAsync(FullPath.FromPath("MyPackage.1.0.0.nupkg"), options);
Available Validation Rules
Default Rules
The following rules are included in NuGetPackageValidationRules.Default:
- AssembliesMustBeOptimized - Ensures assemblies are compiled in Release mode with optimizations enabled
- AuthorMustBeSet - Verifies the author metadata is set and not using default values
- DescriptionMustBeSet - Checks for a meaningful description (not default placeholder text)
- IconMustBeSet - Validates that a package icon is included (not deprecated iconUrl)
- LicenseMustBeSet - Ensures license information is provided (expression or file, not deprecated licenseUrl)
- ProjectUrlMustBeSet - Verifies a project URL is specified and accessible
- ReadmeMustBeSet - Checks that a readme file is included in the package
- RepositoryMustBeSet - Validates repository information is present
- Symbols - Comprehensive validation of debug symbols (PDB files), including:
- Symbol files are present (embedded, .pdb, or .snupkg)
- Deterministic builds are enabled
- Source Link is configured
- Portable PDB format is used (not full PDB)
- Compiler flags are present
- Source files are accessible or embedded
- TagsMustBeSet - Ensures package tags are defined and within length limits
- XmlDocumentationMustBePresent - Verifies XML documentation files are included for public APIs
Additional Rules
These rules are available but not included by default:
- PackageIdAvailableOnNuGetOrg - Checks if the package ID is already taken on nuget.org (useful for new packages)
- RepositoryBranchMustBeSet - Validates that repository branch information is specified
Error Codes
Each validation error has a specific error code for easy identification and filtering:
General Errors (1-10)
1- FileNotFound: Package file not found2- InvalidPackage: Package file cannot be read as a NuGet package
Author Errors (11-20)
11- AuthorNotSet: Author metadata is missing12- DefaultAuthorSet: Author is set to the default value (same as package ID)
License Errors (21-30)
21- LicenseNotSet: License information is missing22- UseDeprecatedLicenseUrl: Using deprecated licenseUrl instead of license expression/file23- LicenseFileNotFound: License file specified but not found in package
Icon Errors (31-40)
31- UseDeprecatedIconUrl: Using deprecated iconUrl instead of icon file32- IconNotSet: No icon specified33- IconNotFound: Icon file not found in package34- IconFileTooLarge: Icon file exceeds size limit35- IconFileFormatNotSupported: Icon file format is not PNG or JPEG36- IconFileInvalidExtension: Icon file extension doesn't match content
Description Errors (41-50)
41- UseDeprecatedSummary: Using deprecated summary field42- DescriptionNotSet: Description is missing43- PackageHasDefaultDescription: Description is using default placeholder text44- PackageDescriptionIsTooLong: Description exceeds maximum length
Project URL Errors (51-60)
51- ProjectUrlNotSet: Project URL is missing52- ProjectUrlNotAccessible: Project URL is not accessible
Readme Errors (61-70)
61- ReadmeNotSet: Readme file is not specified62- ReadmeFileNotFound: Readme file not found in package
Repository Errors (71-80)
71- RepositoryNotSet: Repository metadata is missing72- RepositoryTypeNotSet: Repository type not specified73- RepositoryUrlNotSet: Repository URL not specified74- RepositoryCommitNotSet: Repository commit hash not specified75- RepositoryBranchNotSet: Repository branch not specified
Assembly Errors (81-90)
81- AssemblyIsNotOptimized: Assembly compiled in Debug mode or without optimizations
Package ID Errors (91-100)
91- CannotCheckPackageIdExistsOnNuGetOrg: Unable to verify if package ID exists92- PackageIdExistsOnNuGetOrg: Package ID already exists on nuget.org
XML Documentation Errors (101-110)
101- XmlDocumentationNotFound: XML documentation file not found
Symbol/PDB Errors (111-130)
111- SymbolsNotFound: Debug symbols not found112- NonDeterministic: Build is not deterministic113- SourceFileNotAccessible: Source files not accessible114- CompilerFlagsNotPresent: Compiler flags not embedded in PDB115- InvalidCompilerVersion: Compiler version is invalid116- CompilerDoesNotSupportReproducibleBuilds: Compiler doesn't support reproducible builds117- FullPdb: Using full PDB format instead of portable PDB118- PdbDoesNotMatchAssembly: PDB file doesn't match assembly119- UrlIsNotAccessible: URL referenced in source link is not accessible120- FileHashIsNotValid: File hash validation failed121- FileHashIsNotProvided: File hash not provided122- NotSupportedHashAlgorithm: Hash algorithm not supported
Tag Errors (131-140)
131- TagsNotSet: Package tags are not set132- TagsTooLong: Tags exceed the 4000 character limit
Additional Resources
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. net11.0 is compatible. |
-
net10.0
- Meziantou.Framework.FullPath (>= 3.0.14)
- NuGet.Packaging (>= 7.9.0)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
-
net11.0
- Meziantou.Framework.FullPath (>= 3.0.14)
- NuGet.Packaging (>= 7.9.0)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.17 | 54 | 10/28/2026 |
| 2.0.16 | 68 | 10/24/2026 |
| 2.0.15 | 85 | 10/21/2026 |
| 2.0.14 | 85 | 10/16/2026 |
| 2.0.13 | 87 | 10/14/2026 |
| 2.0.12 | 88 | 10/11/2026 |
| 2.0.11 | 107 | 9/20/2026 |
| 2.0.10 | 105 | 9/15/2026 |
| 2.0.9 | 101 | 9/13/2026 |
| 2.0.8 | 105 | 9/11/2026 |
| 2.0.7 | 126 | 9/9/2026 |
| 2.0.6 | 116 | 9/6/2026 |
| 2.0.5 | 112 | 9/3/2026 |
| 2.0.4 | 114 | 8/30/2026 |
| 2.0.3 | 126 | 8/29/2026 |
| 2.0.2 | 124 | 8/23/2026 |
| 2.0.1 | 146 | 7/8/2026 |
| 2.0.0 | 137 | 7/5/2026 |
| 1.0.47 | 155 | 6/28/2026 |
| 1.0.46 | 137 | 6/22/2026 |