swa-pack-format

Diagnose and fix Static Web Assets pack test assertion failures in .NET SDK.

1.2k|337|Updated Oct 13, 2022
One-click install
npx skills add https://github.com/dotnet/dotnet --skill swa-pack-format
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swa-pack-format
Source: https://github.com/dotnet/dotnet/tree/main/src/sdk/.claude/skills/swa-pack-format
Command: npx skills add https://github.com/dotnet/dotnet --skill swa-pack-format

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When MSBuild .targets logic changes, Static Web Assets pack tests fail because the produced nupkg contents no longer match test assertions, and tracing which MSBuild condition branch applies to a given TFM is tedious and error-prone.

Core Features & Use Cases

  • Condition Tracing: Walks through Microsoft.NET.Sdk.StaticWebAssets.Pack.targets to determine which MSBuild condition branch fires for a test's TFM and configuration.
  • Assertion Updating: Guides updating NuPkgContainsPatterns and NuPkgContain assertions to exactly match the nupkg entries produced by the active branch.
  • Backward-Compatibility Guardrails: Ensures tests targeting older TFMs keep their legacy assertions untouched while only current-branch tests are updated.
  • Use Case: After adding a new feature-flag condition to the pack targets, identify every failing pack test, determine its TFM, and update only the assertions for tests on the changed branch.

Quick Start

Fix the failing StaticWebAssetsPackIntegrationTest assertions by tracing the pack targets conditions for the test's TFM.

Frequently Asked Questions about swa-pack-format

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

FAQPage Schema
How do I fix failing Static Web Assets pack test assertions?

Identify the test's TFM from how it creates the test asset, then trace the Condition attributes in Microsoft.NET.Sdk.StaticWebAssets.Pack.targets to find the active branch. Update the NuPkgContainsPatterns or NuPkgContain assertions to exactly match that branch's nupkg entries.

How do MSBuild conditions affect dotnet pack nupkg contents?

Pack targets use Condition attributes on ItemGroup elements that branch on TFM version, feature flags, and asset presence. Each branch produces a different set of nupkg entries, so test assertions must match the branch activated by the test's configuration.

Should I update pack tests that target older .NET TFMs?

No. Tests explicitly targeting older TFMs verify backward compatibility and their assertions match the legacy nupkg format. Only update tests whose TFM activates the new condition branch; leave older-TFM tests untouched.

Why does a pack test fail after changing .targets files?

Changing conditions, file paths, or included items in pack targets alters the nupkg contents for every TFM branch the change affects. Any test asserting the old contents on those branches fails until its assertions are updated to the new expected entries.

What nupkg paths do Static Web Assets pack tests assert?

Common asserted paths include build/ for build-time imports and manifests, buildMultiTargeting/ and buildTransitive/ for import files, and staticwebassets/ for the actual asset files. Assertions use glob patterns or exact path matching helpers.