The webforms-to-blazor CLI is a powerful command-line tool that automates the first phase of your Web Forms to Blazor migration. It performs deterministic, pattern-based transformations on your Web Forms markup and code-behind to produce Blazor-ready code.
This tool reduces manual migration effort by:
- Removing boilerplate Web Forms directives and syntax
- Converting ASP.NET server controls to BWFC components
- Replacing Web Forms expressions with Blazor syntax
- Extracting code patterns and flagging them with TODO comments for Copilot L2 automation
- Scaffolding a new Blazor project structure with shims and services
The tool processes .aspx, .ascx, and .master files in a fixed sequence, ensuring each transformation builds on the previous one correctly.
dotnet tool install --global Fritz.WebFormsToBlazorcd src/BlazorWebFormsComponents.Cli
dotnet pack
dotnet tool install --global --add-source ./bin/Release Fritz.WebFormsToBlazorwebforms-to-blazor --helpwebforms-to-blazor migrate --input ProductCard.ascx --output ./BlazorComponentswebforms-to-blazor migrate --input ./MyWebFormsProject --output ./MyBlazorProjectThe tool will:
- Scan all
.aspx,.ascx, and.masterfiles - Apply 33 transforms in sequence
- Generate a migration report
- Scaffold supporting files (Program.cs, shims, handlers)
Transforms an entire Web Forms project to Blazor with scaffolding.
webforms-to-blazor migrate \
--input ./MyWebFormsProject \
--output ./MyBlazorProject \
--database SqlServer \
--scaffoldKey Options:
--input <path>— Web Forms project root (required)--output <path>— Blazor output directory (required)--database <provider>— SqlServer, Sqlite, Postgres, Oracle (scaffolds appropriate connection setup)--scaffold— Generate Program.cs, _Imports.razor, App.razor, and shims--dry-run— Preview changes without writing files
Output:
- Converted
.razorfiles - Converted
.razor.cscode-behind - Generated
Program.cswith shim registration - Migration report (
migration-report.json)
Converts individual files without scaffolding. Useful for incremental migrations.
webforms-to-blazor convert \
--input ./Controls/MyControl.ascx \
--output ./Components/MyControl.razorKey Options:
--input <path>— Single.ascxor.aspxfile (required)--output <path>— Output file path--dry-run— Preview transformation
The tool applies 33 transforms organized in three groups:
- Directives (5) — Page, Master, Control, Register, Import directives
- Markup (19) — Controls, expressions, templates, data binding
- Code-Behind (9) — Using statements, base classes, lifecycle, event handlers
See Transform Reference for complete details on each transform, including before/after examples.
The tool inserts TODO comments with standardized category slugs so Copilot L2 skills can automatically follow up on migration work:
// TODO(bwfc-lifecycle): Page_Load → OnInitializedAsync
// TODO(bwfc-ispostback): Review IsPostBack guard for Blazor patterns
// TODO(bwfc-session-state): SessionShim auto-wired via [Inject]See TODO Categories for the complete list of 13 categories and how L2 automation uses them.
After migration, the tool generates a migration-report.json with:
- File-by-file transformation summary
- Manual work items flagged by category
- Severity levels (Info, Warning, Error)
- Precise file locations and line numbers
See Report Format for schema and examples.
This tool handles Level 1 transformations only:
- ✅ Markup and directive conversion
- ✅ Pattern detection and guidance
- ✅ Boilerplate removal
- ❌ Logic rewriting (use Copilot L2 skills for this)
After running the CLI:
- Review TODO comments — each one points to a specific migration pattern
- Run Copilot L2 skills — automated follow-up transforms for complex patterns
- Build and test — verify your Blazor project compiles and runs
- Manual tweaks — business logic, styling, third-party integrations
# 1. Scan and transform
webforms-to-blazor migrate \
--input ./MyApp.Web \
--output ./MyApp.Blazor \
--database SqlServer \
--scaffold
# 2. Review migration report
cat MyApp.Blazor/migration-report.json | jq '.manualItems[] | select(.severity == "Error")'
# 3. Build and identify missing pieces
cd MyApp.Blazor
dotnet build
# 4. Use Copilot CLI for L2 automation
copilot /webforms-migration- Transform Reference — See what each transform does with before/after examples
- TODO Conventions — Understand the TODO categories for L2 automation
- Report Schema — Interpret the migration report
- Migration Strategies — Learn the full migration approach