Meziantou.Framework.NuGetPackageValidation
1.0.23
Prefix Reserved
See the version list below for details.
dotnet add package Meziantou.Framework.NuGetPackageValidation --version 1.0.23
NuGet\Install-Package Meziantou.Framework.NuGetPackageValidation -Version 1.0.23
<PackageReference Include="Meziantou.Framework.NuGetPackageValidation" Version="1.0.23" />
<PackageVersion Include="Meziantou.Framework.NuGetPackageValidation" Version="1.0.23" />
<PackageReference Include="Meziantou.Framework.NuGetPackageValidation" />
paket add Meziantou.Framework.NuGetPackageValidation --version 1.0.23
#r "nuget: Meziantou.Framework.NuGetPackageValidation, 1.0.23"
#:package Meziantou.Framework.NuGetPackageValidation@1.0.23
#addin nuget:?package=Meziantou.Framework.NuGetPackageValidation&version=1.0.23
#tool nuget:?package=Meziantou.Framework.NuGetPackageValidation&version=1.0.23
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
using Meziantou.Framework.NuGetPackageValidation;
// Validate a package with default rules
var result = await NuGetPackageValidator.ValidateAsync("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 != null)
{
Console.WriteLine($" Help: {error.HelpText}");
}
}
}
Custom Rules
// Validate with specific rules only
var result = await NuGetPackageValidator.ValidateAsync(
"MyPackage.1.0.0.nupkg",
new[]
{
NuGetPackageValidationRules.AuthorMustBeSet,
NuGetPackageValidationRules.LicenseMustBeSet,
NuGetPackageValidationRules.IconMustBeSet
});
Custom Options
var options = new NuGetPackageValidationOptions();
// Add default rules
foreach (var rule in NuGetPackageValidationRules.Default)
{
options.Rules.Add(rule);
}
// Exclude specific error codes
options.ExcludedRuleIds.Add(ErrorCodes.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("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 found
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 | 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 is compatible. 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 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. |
-
net10.0
- Meziantou.Framework.FullPath (>= 1.1.5)
- NuGet.Packaging (>= 6.14.0)
-
net8.0
- Meziantou.Framework.FullPath (>= 1.1.5)
- NuGet.Packaging (>= 6.14.0)
-
net9.0
- Meziantou.Framework.FullPath (>= 1.1.5)
- NuGet.Packaging (>= 6.14.0)
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 |
|---|---|---|
| 1.0.25 | 48 | 11/9/2025 |
| 1.0.24 | 108 | 11/2/2025 |
| 1.0.23 | 163 | 10/27/2025 |
| 1.0.22 | 126 | 10/26/2025 |
| 1.0.21 | 101 | 10/19/2025 |
| 1.0.20 | 284 | 9/16/2025 |
| 1.0.19 | 187 | 9/3/2025 |
| 1.0.18 | 157 | 8/21/2025 |
| 1.0.17 | 170 | 8/14/2025 |
| 1.0.16 | 153 | 5/18/2025 |
| 1.0.15 | 140 | 3/1/2025 |
| 1.0.14 | 139 | 11/17/2024 |
| 1.0.13 | 176 | 6/15/2024 |
| 1.0.12 | 285 | 11/15/2023 |
| 1.0.11 | 264 | 6/27/2023 |
| 1.0.10 | 219 | 6/27/2023 |
| 1.0.9 | 328 | 3/13/2023 |
| 1.0.8 | 373 | 2/11/2023 |
| 1.0.7 | 549 | 10/11/2022 |
| 1.0.6 | 521 | 10/9/2022 |
| 1.0.5 | 515 | 10/7/2022 |
| 1.0.4 | 512 | 10/1/2022 |
| 1.0.3 | 556 | 9/24/2022 |
| 1.0.2 | 531 | 9/8/2022 |
| 1.0.0 | 526 | 9/7/2022 |