Verify.Nupkg 3.0.1

Prefix Reserved
dotnet add package Verify.Nupkg --version 3.0.1                
NuGet\Install-Package Verify.Nupkg -Version 3.0.1                
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="Verify.Nupkg" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Verify.Nupkg --version 3.0.1                
#r "nuget: Verify.Nupkg, 3.0.1"                
#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.
// Install Verify.Nupkg as a Cake Addin
#addin nuget:?package=Verify.Nupkg&version=3.0.1

// Install Verify.Nupkg as a Cake Tool
#tool nuget:?package=Verify.Nupkg&version=3.0.1                

Icon

Verify.Nupkg

Build status Nuget Downloads

Extends Verify to allow verification of NuGet .nupkg files.

The plugin does not do a naive binary comparison, as that would cause a large amount of verification churn. Instead, the contents of the .nuspec file are verified, along with a tree view of the package files.

Here's an example of the diff that results from adding a README to the package:

--- a/manifest.verified.nuspec
+++ b/manifest.verified.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>SamplePackage</id>
    <version>********</version>
    <authors>SamplePackage</authors>
+    <readme>README.md</readme>
    <description>Package Description</description>
    <repository type="git" commit="****************************************" />
    <dependencies>
      <group targetFramework="net8.0" />
    </dependencies>
  </metadata>
</package>

--- a/contents.verified.txt
+++ b/contents.verified.txt
/
+|-- README.md
|-- SamplePackage.nuspec
|-- lib
|   |-- net8.0
|   |   |-- SamplePackage.dll

Verifying package structure is part of an overall solution to prevent accidental package breaks. If you want to verify / avoid breaking API changes, check out Microsoft.CodeAnalysis.PublicApiAnalyzers. If you want to follow packing best practices (validating a README, reproducible builds, etc.) check out meziantou's blog post.

Usage

[ModuleInitializer]
public static void Initialize() =>
    VerifyNupkg.Initialize();

File path

[Fact]
public Task VerifyNupkgFile()
{
    string packagePath = "path/to/package.nupkg";

    VerifySettings settings = new();
    settings.UseUniqueDirectory(); // Optional; group files into a directory
    settings.ScrubNuspec(); // Scrub commit and other volatile information from nuspec

    return VerifyFile(packagePath, settings);
}
Excluding files

By default, the following files are excluded from the directory listing baseline:

  • [Content_Types].xml
  • .psmdcp
  • _rels/.rels

If you'd to customize the file exclusion list, use VerifySettings.AddNupkgDiffSettings().

VerifySettings settings = new();
settings.AddNupkgDiffSettings(settings =>
{
    settings.ExcludedFiles = [new Regex(@"\.psmdcp$"), new Regex(@"^\[Content_Types\].xml$")];
});

Custom scrubbers

.nuspec files often contain sources of verification churn. Use VerifierSettings.ScrubNuspec() like this:

VerifySettings settings = new();
settings.ScrubNuspec();

which itself is a convenience method for ScrubNuspecVersion() and ScrubNuspecCommit(). Feel free to use them separately if you'd like to verify either of these values.

Referencing / locating a package built in the same solution

Verify is ideally suited for writing integration / snapshot tests of NuGet package contents. However, ensuring a project creates a fresh NuGet package and locating it for testing can be fragile.

To simplify the process, consider using GetPackFromProject to build the NuGet package for your <ProjectReference>s and place them in the test's output directory for easy locating.

ASCII tree

The ASCII art tree is inspired by the tree command, but with a few modifications to reduce the amount of "noise" that occurs in diffs when files are added / removed.

Icon

Package designed by sandra from The Noun Project.

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. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

  • net8.0

  • net9.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
3.0.1 73 3/9/2025
2.0.1 236 3/4/2025
1.1.6 2,883 6/28/2024
1.1.5 656 6/3/2024
1.1.1 302 3/30/2024
1.0.16 183 3/22/2024
1.0.15 209 2/22/2024
1.0.13 149 2/12/2024
1.0.6 165 2/6/2024
1.0.3 155 2/6/2024