Skip to content
Skillpedia
APIs & servers (backend)40k · #5345

resx-source-generator-migration

Updates a project to use a more modern method of managing resources. It swaps the old system for a new, more efficient one.

What it does

This code helps update your software projects. It replaces an old way of handling resource files (texts, messages) with a more modern and efficient one, using a 'source code generator'.

When to use it

  • ✓When you want to modernize an old project.
  • ✓When optimizing your program's performance.
  • ✓To simplify how texts are managed.

Example of what to ask your AI

“Migrate my project 'MyProject.csproj' to use the source generator for .resx files.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/resx-source-generator-migration/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/resx-source-generator-migration/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It adds a new tool to your project and removes old configurations that created extra code files. This causes the code to access texts to be generated automatically.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add github/awesome-copilot --skill resx-source-generator-migration

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/resx-source-generator-migration/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Your goal is to migrate the project to use a source-generator for .resx files instead of checked-in .designer.cs files.

User Input

Amend the instructions below with the following user input. The user input is likely to be an absolute or repo-relative path to an msbuild project file or a directory containing an msbuild project to be migrated.

$ARGUMENTS

Migration

Complete each of the following sub-sections.

Opt into the source generator

Inspect the target's package-management setup and configured NuGet sources before adding the package:

  1. If the repository centrally manages package versions and already has a PackageVersion for Microsoft.CodeAnalysis.ResxSourceGenerator, add this versionless reference to an ItemGroup in the project file:
<PackageReference Include="Microsoft.CodeAnalysis.ResxSourceGenerator" PrivateAssets="all" />
  1. If no central version exists, select a package version compatible with the target SDK/compiler and follow the repository's established version-management pattern. Specify the version on the PackageReference or add the corresponding central PackageVersion.
  2. Verify that the configured NuGet sources can resolve the selected package. If they cannot, ask the user before changing feed configuration.

Remove traces of .resx code-behind files

Search for any msbuild items related to resx files. They typically come in pairs, as shown below:

<ItemGroup>
  <Compile Update="Strings.Designer.cs">
    <DesignTime>True</DesignTime>
    <AutoGen>True</AutoGen>
    <DependentUpon>Strings.resx</DependentUpon>
  </Compile>
</ItemGroup>

<ItemGroup>
  <EmbeddedResource Update="Strings.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Strings.Designer.cs</LastGenOutput>
  </EmbeddedResource>
</ItemGroup>

Note that you might also find <Generator>PublicResXFileCodeGenerator</Generator> (or <CustomTool> instead of <Generator>) as .resx item metadata.

For each strongly typed .resx file being migrated, identify its generated designer file using all of these signals:

  • LastGenOutput metadata on the EmbeddedResource item;
  • a Compile item whose DependentUpon metadata names the .resx file; and
  • a matching *.Designer.cs file on disk, even when the SDK includes it implicitly and no Compile item exists.

Before deleting a candidate, inspect its contents and confirm it is a generated resource accessor, such as a class containing ResourceManager, Culture, and properties that retrieve resource values. A matching filename alone is not sufficient. Do not delete WinForms or control designer files that contain UI initialization such as InitializeComponent; these commonly sit beside a same-named .resx file, and their DependentUpon metadata points to the form or control source file rather than the .resx file.

Also confirm that every resource exposed by the designer is a string and that the .resx file contains no images, icons, byte arrays, serialized objects, or other non-string values. This source generator emits string accessors backed by ResourceManager.GetString; it is not a compatible replacement for non-string resource properties. If any non-string resource exists, do not delete the designer or migrate that resource file. Keep its existing generation approach, or set <GenerateSource>false</GenerateSource> if the package would otherwise process it.

Before deletion, search the solution for every use and declaration of the accessor type. ResXFileCodeGenerator emits a non-static class, while this source generator emits a static partial class. Identify object construction, instance access, inheritance, use as a generic type argument (including IStringLocalizer<T>), and existing partial declarations with instance members, base types, or interfaces. Refactor each incompatible use to the static generated API and make every partial declaration compatible before migrating. If that is not appropriate, retain the existing designer and set <GenerateSource>false</GenerateSource> for that resource file.

For each associated designer file:

  1. Delete the *.Designer.cs file from disk.
  2. Remove its explicit MSBuild item from the project when one exists.

Update EmbeddedResource items

…

FAQ

What are .resx files?

These are files that store texts and messages used in your program, like button labels and error messages, to make translation and management easier.

What is a 'source code generator'?

It's a tool that writes code automatically for you, based on other information. In this case, it generates the code to access the texts from .resx files.

Do I need to worry about .Designer.cs files?

No, the goal of this update is precisely to eliminate the need for these automatically generated .Designer.cs files, making the process cleaner.

Details

Original description by the author

Migrates a project that uses checked-in .designer.cs files behind .resx to using a source-generator instead

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5345
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills