nuget-restore-repro-triage

Writes C# tests reproducing NuGet restore bugs from GitHub issues.

1.2k|337|Updated Oct 13, 2022
One-click install
npx skills add https://github.com/dotnet/dotnet --skill nuget-restore-repro-triage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nuget-restore-repro-triage
Source: https://github.com/dotnet/dotnet/tree/main/src/nuget-client/.agents/skills/nuget-restore-repro-triage
Command: npx skills add https://github.com/dotnet/dotnet --skill nuget-restore-repro-triage

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Investigating NuGet restore bugs reported in NuGet/Home requires manually translating issue reports into reproducible test cases, which is slow and error-prone without deep knowledge of the NuGet.Client test infrastructure.

Core Features & Use Cases

  • Issue Analysis: Extracts repro-relevant data from GitHub issues including error codes, package graphs, project configuration, and expected versus actual behavior.
  • Test Authoring: Generates C# tests in the NuGet.Client repo using SimpleTestPathContext, SimpleTestPackageContext, and RestoreCommand, with guidance on choosing between in-process functional tests and dotnet CLI integration tests.
  • Bug-First Assertions: Structures tests to first assert the buggy behavior to prove reproduction, then assert the correct behavior expected after the fix.
  • Use Case: Given an issue reporting NU1102 instead of NU1004 when lock file pruning data changes, produce a two-phase locked-mode restore test that reproduces the wrong error code and documents the correct one.

Quick Start

Analyze NuGet/Home issue 14727 and write a C# test in NuGet.Commands.FuncTest that reproduces the reported restore failure.

Frequently Asked Questions about nuget-restore-repro-triage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a test that reproduces a NuGet restore bug?

Extract the error codes, package graph, and project configuration from the issue, then build a minimal package graph with SimpleTestPackageContext, publish it to a local feed, define a PackageSpec via JSON, and run RestoreCommand. First assert the buggy behavior to confirm reproduction, then assert the correct behavior.

How do I test NuGet lock file and locked mode restore behavior?

Set RestoreLockProperties with restorePackagesWithLockFile on the PackageSpec, run an initial restore and call CommitAsync to write the lock file, then switch restoreLockedMode to true and restore again. Assert the expected error code such as NU1004 via logger.ErrorMessages or LockFile.LogMessages.

When should I use DotnetRestoreTests instead of RestoreCommand functional tests?

Use DotnetRestoreTests only when the bug depends on real MSBuild evaluation, SDK-injected props or targets, command-line property overrides, or solution file parsing. Prefer in-process RestoreCommand tests for anything expressible as a PackageSpec, since they are faster and deterministic.

How do I test NuGet central package management scenarios?

Set centralPackageVersionsManagementEnabled to true in the restore section of the PackageSpec JSON, mark each dependency with versionCentrallyManaged, and define centralPackageVersions per framework. Add CentralPackageTransitivePinningEnabled for transitive pinning scenarios.

Why should a repro test assert the buggy behavior first?

Asserting the buggy behavior first proves the test actually reproduces the reported issue rather than passing vacuously. Once confirmed, the assertion is swapped to the correct behavior so the test only passes after the fix lands.