{"record":{"id":"4633a9d91d0398af","repo":"dotnet/reactive","slug":"unexpected-failure-when-building-nuget-package-to-be","errorCode":null,"errorMessage":"Unexpected failure when building NuGet package to be consumed by test app","messagePattern":"Unexpected failure when building NuGet package to be consumed by test app","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Test/Gauntlet/Checks/TransitiveReferences/CheckTransitiveFrameworkReference/RunTransitiveFrameworkReferenceCheck.cs","lineNumber":134,"sourceCode":"                            // to a legacy facade, but a component has a reference to System.Reactive v7. I don't think\n                            // that's a thing a library should ever do but perhaps we need to test it.\n\n                            var replaceSystemReactiveWith = ld.HasWindowsTargetUsingUiFrameworkSpecificRxFeature\n                                ? [.. newRxMainAndIfRequiredLegacyPackage, .. rxUiPackages]\n                                : newRxMainAndIfRequiredLegacyPackage;\n                            project.ReplacePackageReference(\"System.Reactive\", replaceSystemReactiveWith);\n                        }\n\n                        if (!ld.HasWindowsTargetUsingUiFrameworkSpecificRxFeature)\n                        {\n                            project.ReplaceProperty(\"_ScenarioWindowsDefineConstants\", \"\");\n                        }\n                    },\n                    additionalPackageSources);\n\n                if (!packageBuildResult.BuildSucceeded)\n                {\n                    throw new InvalidOperationException(\"Unexpected failure when building NuGet package to be consumed by test app\");\n                }\n\n                _builtLibPackages.Add(ld, new PackageIdAndVersion(assemblyName, packageVersion));\n            }\n        }\n\n        RxDependency[] libs =\n            [\n                ..scenario.RxDependenciesBefore,\n                ..scenario.RxDependenciesAfter,\n            ];\n        foreach (var dependency in libs)\n        {\n            await dependency.Match(\n                (DirectRxPackageReference _) => Task.CompletedTask,\n                ProcessLib);\n        }\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Test/Gauntlet/Checks/TransitiveReferences/CheckTransitiveFrameworkReference/RunTransitiveFrameworkReferenceCheck.cs#L116-L152","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var pack = dotnet pack -c Release <libProject> -o <out>;\nif (pack.ExitCode != 0 || !Directory.GetFiles(out, \"*.nupkg\").Any())\n    throw new InvalidOperationException(\"Pack will fail; fix errors before running the check\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await check.RunScenarioAsync(...);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"building NuGet package\"))\n{\n    // inspect pack log, fix compile/pack error, re-run\n}","preventionTips":["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"],"tags":["nuget","build","pack","test-harness"],"backgroundTag":"command-not-found","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}