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
- Check the pack output log for where the nupkg was actually written and fix OutputFolder assumptions
- Run dotnet pack manually and confirm a .nupkg is produced in the expected folder
- Verify the project is packable (has package metadata / IsPackable=true)
- 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
- Pass an explicit -o output folder to dotnet pack and use that same folder for searching
- Ensure the project is packable (IsPackable, package metadata present)
- Clean bin/obj if pack output is unexpectedly missing
- Log the full pack stdout so the real nupkg location is visible
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
- Unexpected failure when building NuGet package to be…
- Multiple .nupkg files found after packing the project
- PlugIn host executable not found at
- Template csproj path should be absolute
- Template csproj path should refer to a file, not a directory
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)