dotnet/reactive · error · InvalidOperationException

No .nupkg file found after packing the project

Error message

No .nupkg file found after packing the project

What it means

ComponentBuilder.BuildLocalNuGetPackageAsync runs dotnet pack and then searches the output folder recursively for *.nupkg files. The result is pattern-matched: an empty list throws InvalidOperationException('No .nupkg file found after packing the project'), meaning pack claimed success but produced no package file.

Solutions

  1. Check the pack output log for where the nupkg was actually written and fix OutputFolder assumptions
  2. Run dotnet pack manually and confirm a .nupkg is produced in the expected folder
  3. Verify the project is packable (has package metadata / IsPackable=true)
  4. Clear bin/obj and re-run to rule out stale or cleaned output
Defensive patterns

Strategy: validation

Validate before calling

if (pack.ExitCode != 0) throw new InvalidOperationException("dotnet pack failed");
if (!Directory.EnumerateFiles(outDir, "*.nupkg", SearchOption.AllDirectories).Any())
    throw new InvalidOperationException("Pack produced no nupkg; check -o path");

Try / catch

try
{
    var results = await builder.BuildLocalNuGetPackageAsync(...);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("No .nupkg file found"))
{
    // inspect pack log/output folder, fix output path, retry
}

Prevention

When it happens

Trigger: Directory.GetFiles(packResults.OutputFolder, '*.nupkg', AllDirectories) returns zero entries even though the pack command exited successfully.

Common situations: dotnet pack ran with wrong output path so the nupkg landed outside OutputFolder; pack skipped packaging (no Packable targets); a stale output-folder expectation after SDK changes; output cleaned between pack and search.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/47270240805093aa. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Test/Gauntlet/RxGauntlet.Common/Build/ComponentBuilder.cs:32

        Action<ProjectFileRewriter> modifyProjectFile,
        (string FeedName, string FeedLocation)[]? additionalPackageSources)
    {
        (string projectTemplateFileName, ModifiedProjectClone projectClone) = CreateModifiedProjectClone(
            PackageTempFolderName, templateCsProj, modifyProjectFile, additionalPackageSources);

        BuildOutput packResults = await projectClone.RunDotnetPack(projectTemplateFileName);

        if (!Directory.Exists(LocalNuGetPackageFolderPath))
        {
            Directory.CreateDirectory(LocalNuGetPackageFolderPath);
        }

        string nupkgPath = Directory.GetFiles(
            packResults.OutputFolder,
            "*.nupkg",
            SearchOption.AllDirectories) switch
        {
            [] => throw new InvalidOperationException("No .nupkg file found after packing the project"),
            [string nupkgFile] => nupkgFile,
            _ => throw new InvalidOperationException("Multiple .nupkg files found after packing the project")
        };

        string destinationNupkgPath = Path.Combine(LocalNuGetPackageFolderPath, Path.GetFileName(nupkgPath));
        File.Copy(nupkgPath, destinationNupkgPath);

        return packResults;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="templateCsProj"></param>
    /// <param name="modifyProjectFile"></param>
    /// <param name="additionalPackageSources"></param>
    /// <returns>
    /// A task that produces the path to the <c>bin\Release</c> folder of the built application.

View on GitHub (pinned to 94b5d5ab91)