dotnet/reactive · error · InvalidOperationException
Unexpected failure when building NuGet package to be consume
Error message
Unexpected failure when building NuGet package to be consumed by test app
What it means
RunTransitiveFrameworkReferenceCheck.RunScenarioAsync builds a local NuGet package that a test app will consume; if dotnet pack reports BuildSucceeded == false it throws InvalidOperationException('Unexpected failure when building NuGet package to be consumed by test app'). The library treats a failed pack as a scenario failure because the transitive-reference check cannot proceed without the package.
Solutions
- Inspect the pack build log (packageBuildResult output) for the real compiler/pack error and fix it
- Verify additionalPackageSources contains all feeds needed to restore dependencies
- Run dotnet pack on the project manually to reproduce the failure
- Clear bin/obj and retry to rule out stale build state
Defensive patterns
Strategy: try-catch
Validate before calling
var pack = dotnet pack -c Release <libProject> -o <out>;
if (pack.ExitCode != 0 || !Directory.GetFiles(out, "*.nupkg").Any())
throw new InvalidOperationException("Pack will fail; fix errors before running the check"); Try / catch
try
{
await check.RunScenarioAsync(...);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("building NuGet package"))
{
// inspect pack log, fix compile/pack error, re-run
} Prevention
- Keep the library project compiling cleanly before running transitive-reference checks
- Ensure all required NuGet sources are passed in additionalPackageSources
- Validate package metadata (id/version) before pack
- Regularly clear bin/obj to avoid stale build state
When it happens
Trigger: The inner NuGet pack step (run with additionalPackageSources) returns a result whose BuildSucceeded is false — a compile error or pack failure in the library project being packaged.
Common situations: C# compile error in the source being packed; missing NuGet feed in additionalPackageSources; pack target failing due to invalid package metadata (ids, versions); stale obj/bin state.
Related errors
- No .nupkg file found after packing the project
- Multiple .nupkg files found after packing the project
- PlugIn host executable not found at {plugInHostExecutablePat
- Did not get output from program
- Did not get output from program
AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15).
Data as JSON: /api/errors/4633a9d91d0398af.
Report an issue: GitHub.
Appendix: source
Thrown at Rx.NET/Test/Gauntlet/Checks/TransitiveReferences/CheckTransitiveFrameworkReference/RunTransitiveFrameworkReferenceCheck.cs:134
// to a legacy facade, but a component has a reference to System.Reactive v7. I don't think
// that's a thing a library should ever do but perhaps we need to test it.
var replaceSystemReactiveWith = ld.HasWindowsTargetUsingUiFrameworkSpecificRxFeature
? [.. newRxMainAndIfRequiredLegacyPackage, .. rxUiPackages]
: newRxMainAndIfRequiredLegacyPackage;
project.ReplacePackageReference("System.Reactive", replaceSystemReactiveWith);
}
if (!ld.HasWindowsTargetUsingUiFrameworkSpecificRxFeature)
{
project.ReplaceProperty("_ScenarioWindowsDefineConstants", "");
}
},
additionalPackageSources);
if (!packageBuildResult.BuildSucceeded)
{
throw new InvalidOperationException("Unexpected failure when building NuGet package to be consumed by test app");
}
_builtLibPackages.Add(ld, new PackageIdAndVersion(assemblyName, packageVersion));
}
}
RxDependency[] libs =
[
..scenario.RxDependenciesBefore,
..scenario.RxDependenciesAfter,
];
foreach (var dependency in libs)
{
await dependency.Match(
(DirectRxPackageReference _) => Task.CompletedTask,
ProcessLib);
}
View on GitHub (pinned to 94b5d5ab91)