resx-source-generator-migration

Migrates .NET projects from checked-in .resx designer files to source-generated resource accessors.

38.5k|4.9k|Updated Jun 11, 2025
One-click install
npx skills add https://github.com/github/awesome-copilot --skill resx-source-generator-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: resx-source-generator-migration
Source: https://github.com/github/awesome-copilot/tree/main/skills/resx-source-generator-migration
Command: npx skills add https://github.com/github/awesome-copilot --skill resx-source-generator-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

.NET projects often check in auto-generated .Designer.cs files behind .resx resources, creating noisy diffs, merge conflicts, and stale generated code. This Skill migrates a project to the Microsoft.CodeAnalysis.ResxSourceGenerator package so resource accessors are generated at build time instead of being committed to source control.

Core Features & Use Cases

  • Package Setup: Adds the Microsoft.CodeAnalysis.ResxSourceGenerator PackageReference while respecting central package management and configured NuGet feeds.
  • Safe Designer Removal: Identifies and deletes generated .Designer.cs files only after verifying they are string-only resource accessors, preserving WinForms designer files and non-string resources.
  • MSBuild Metadata Migration: Rewrites EmbeddedResource items by removing Generator, LastGenOutput, and CustomTool metadata, converting CustomToolNamespace to ClassName, and setting GenerateSource=false where generation is unsafe.
  • Use Case: A repository with dozens of Strings.Designer.cs files causing constant merge conflicts can be migrated in one pass, with the build validated and resource access verified afterward.

Quick Start

Migrate the project at src/MyApp/MyApp.csproj to use the resx source generator instead of checked-in designer files.

Frequently Asked Questions about resx-source-generator-migration

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

FAQPage Schema
How do I migrate .resx files to a source generator in .NET?

Add a PackageReference to Microsoft.CodeAnalysis.ResxSourceGenerator, delete the generated .Designer.cs files, and remove Generator and LastGenOutput metadata from EmbeddedResource items. The generator then produces strongly typed accessors at build time.

How do I replace ResXFileCodeGenerator with Microsoft.CodeAnalysis.ResxSourceGenerator?

Remove the Generator or CustomTool metadata from each EmbeddedResource item and delete the matching designer file. If the old metadata was PublicResXFileCodeGenerator, add Public=true metadata to keep the generated accessor public.

Does the resx source generator support non-string resources like images?

No. The generator emits string accessors backed by ResourceManager.GetString, so .resx files containing images, icons, byte arrays, or serialized objects must keep their existing designer or set GenerateSource=false on the EmbeddedResource item.

Why does the build fail after migrating resx files to the source generator?

Common causes are instance-based usage of the old non-static designer class, partial declarations with instance members, or a type and namespace sharing the same name. Refactor usages to the static API or move the .resx file to resolve the conflict.

How do I handle CustomToolNamespace when migrating resx files?

Either drop CustomToolNamespace and accept the default generated namespace, optionally adding using aliases in affected files, or replace it with ClassName metadata containing the full namespace and class name such as MyNamespace.MyResources.