swa-baseline-regeneration

Regenerates Static Web Assets test baseline JSON files after legitimate build output changes.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Static Web Assets tests in the .NET SDK fail with "generated manifest should match the expected baseline" errors whenever build output legitimately changes, and manually updating the embedded baseline JSON files is error-prone because the test DLL must be rebuilt before validation works.

Core Features & Use Cases

  • Baseline Regeneration Workflow: Step-by-step PowerShell procedure using the ASPNETCORE_TEST_BASELINES environment variable to rewrite baseline JSON files from actual build output.
  • Embedded Resource Handling: Explains why the test project must be rebuilt after regeneration, since baselines are compiled into the test DLL via Assembly.GetManifestResourceStream.
  • Use Case: After changing Razor SDK build logic, run the affected StaticWebAssets tests with the regeneration flag, rebuild the test project, then validate without the flag to confirm the new baselines pass.

Quick Start

Regenerate the failing Static Web Assets test baselines and validate that the updated tests pass.

Frequently Asked Questions about swa-baseline-regeneration

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

FAQPage Schema
How do I fix "generated manifest should match the expected baseline" test failures?

Set the ASPNETCORE_TEST_BASELINES environment variable to true and rerun the failing tests to rewrite the baseline JSON files from actual output. Then rebuild the test project and rerun the tests without the flag to validate.

Where are Static Web Assets baseline files stored in dotnet/sdk?

Baselines live in test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetsBaselines/. Each test has Build and Publish variants with .staticwebassets.json manifest files and .files.json expected file lists.

Why do baseline tests still fail after regenerating the JSON files?

Baselines are embedded resources compiled into the test DLL, so the test project must be rebuilt after regeneration. Without the rebuild, tests still compare against the old embedded baselines and fail.

What do ${ProjectPath} and ${Tfm} mean in baseline JSON files?

They are template variables that make baselines portable across machines. StaticWebAssetsBaselineFactory.ToTemplate() replaces actual paths with ${ProjectPath}, ${RestorePath}, and ${Tfm} before comparing against the stored baseline.

Can I regenerate baselines with a script instead of manual commands?

Yes, the repo includes src/RazorSdk/update-test-baselines.ps1, which runs dotnet test with the ASPNETCORE_TEST_BASELINES environment variable and a TestCategory=BaselineTest filter, followed by a validation run.