Meziantou.Framework.NuGetPackageValidation 1.0.25

Prefix Reserved
dotnet add package Meziantou.Framework.NuGetPackageValidation --version 1.0.25
                    
NuGet\Install-Package Meziantou.Framework.NuGetPackageValidation -Version 1.0.25
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.NuGetPackageValidation" Version="1.0.25" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.NuGetPackageValidation" Version="1.0.25" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.NuGetPackageValidation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.NuGetPackageValidation --version 1.0.25
                    
#r "nuget: Meziantou.Framework.NuGetPackageValidation, 1.0.25"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.NuGetPackageValidation@1.0.25
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.NuGetPackageValidation&version=1.0.25
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.NuGetPackageValidation&version=1.0.25
                    
Install as a Cake Tool

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 missing
  • 12 - DefaultAuthorSet: Author is set to the default value (same as package ID)

License Errors (21-30)

  • 21 - LicenseNotSet: License information is missing
  • 22 - UseDeprecatedLicenseUrl: Using deprecated licenseUrl instead of license expression/file
  • 23 - LicenseFileNotFound: License file specified but not found in package

Icon Errors (31-40)

  • 31 - UseDeprecatedIconUrl: Using deprecated iconUrl instead of icon file
  • 32 - IconNotSet: No icon specified
  • 33 - IconNotFound: Icon file not found in package
  • 34 - IconFileTooLarge: Icon file exceeds size limit
  • 35 - IconFileFormatNotSupported: Icon file format is not PNG or JPEG
  • 36 - IconFileInvalidExtension: Icon file extension doesn't match content

Description Errors (41-50)

  • 41 - UseDeprecatedSummary: Using deprecated summary field
  • 42 - DescriptionNotSet: Description is missing
  • 43 - PackageHasDefaultDescription: Description is using default placeholder text
  • 44 - PackageDescriptionIsTooLong: Description exceeds maximum length

Project URL Errors (51-60)

  • 51 - ProjectUrlNotSet: Project URL is missing
  • 52 - ProjectUrlNotAccessible: Project URL is not accessible

Readme Errors (61-70)

  • 61 - ReadmeNotSet: Readme file is not specified
  • 62 - ReadmeFileNotFound: Readme file not found in package

Repository Errors (71-80)

  • 71 - RepositoryNotSet: Repository metadata is missing
  • 72 - RepositoryTypeNotSet: Repository type not specified
  • 73 - RepositoryUrlNotSet: Repository URL not specified
  • 74 - RepositoryCommitNotSet: Repository commit hash not specified
  • 75 - 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 exists
  • 92 - 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 found
  • 112 - NonDeterministic: Build is not deterministic
  • 113 - SourceFileNotAccessible: Source files not accessible
  • 114 - CompilerFlagsNotPresent: Compiler flags not embedded in PDB
  • 115 - InvalidCompilerVersion: Compiler version is invalid
  • 116 - CompilerDoesNotSupportReproducibleBuilds: Compiler doesn't support reproducible builds
  • 117 - FullPdb: Using full PDB format instead of portable PDB
  • 118 - PdbDoesNotMatchAssembly: PDB file doesn't match assembly
  • 119 - UrlIsNotAccessible: URL referenced in source link is not accessible
  • 120 - FileHashIsNotValid: File hash validation failed
  • 121 - FileHashIsNotProvided: File hash not provided
  • 122 - NotSupportedHashAlgorithm: Hash algorithm not supported

Tag Errors (131-140)

  • 131 - TagsNotSet: Package tags are not set
  • 132 - TagsTooLong: Tags exceed the 4000 character limit

Additional Resources

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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