Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
GitHub Copilot app modernization executes reusable, task-focused guidance stored as custom upgrade instruction files. During an upgrade, incorporate these instructions into the generated plan so Copilot applies opinionated replacements, refactorings, or policy-driven changes. For example, replacing Newtonsoft.Json with System.Text.Json.
This article shows how to create a custom upgrade instruction, test it with a fast inner loop, and apply it automatically during a full upgrade.
Prerequisites
Before you begin, ensure you have these requirements:
Windows Operating System
Visual Studio 2026 (or Visual Studio 2022 version 17.14.17 or newer).
.NET desktop development workload with the following optional components enabled:
- GitHub Copilot
- GitHub Copilot app modernization for .NET
Copilot license and supported subscription plan:
Sign in to Visual Studio using a GitHub account with Copilot access.
Supported subscription plans:
- Copilot Pro
- Copilot Pro+
- Copilot Business
- Copilot Enterprise
Important
If you change subscriptions, you must restart Visual Studio.
Code must be written in C#.
Understand custom upgrade instructions
Custom upgrade instructions are markdown files that Copilot retrieves on demand while planning or executing an upgrade. They differ from copilot-instructions.md because they're:
- Targeted to automating code and dependency changes.
- Retrieved only when relevant to the current user request or plan modification.
- Reusable across solutions when copied into each repository.
Structure your instruction files with:
- A short title describing the action. For example, "replace Newtonsoft.Json with System.Text.Json."
- A concise problem statement or prerequisite section.
- Explicit step logic ("If X is found, do Y")—avoid vague language.
- (Recommended) One or more diff examples captured from actual local edits to guide transformations.
Create a custom upgrade instruction
Follow these steps to generate and refine a new instruction file. These sections focus on replacing Newtonsoft.Json with System.Text.Json to explain this feature with an example.
- In the Solution Explorer window, right-click the solution > Modernize.
- In the chat, type:
I want to generate a custom upgrade instruction. - When asked, provide a scenario like
I want to replace Newtonsoft with System.Text.Jsonto have Copilot create the file. - (Optional) Add the file to the solution for visibility if it isn't already included.
- When Copilot creates the new file, such as
replace_newtonsoft_with_system_text_json.md, review the content and refine it in chat. For example, ask Copilot to "clarify detection criteria" or "add a prerequisite section." - (Recommended) Strengthen the instruction with a real diff example:
- Make the desired code changes manually in one project. For example, "remove the
Newtonsoft.Jsonpackage, update using directives, and replaceJsonConvertcode withJsonSerializer." - In chat, with the instruction file open, type:
Check my git changes and add diffs as examples to my instruction file. - Confirm Copilot used a git diff and appended a fenced diff block or structured example to the markdown file.
- Make the desired code changes manually in one project. For example, "remove the
Authoring tips
- Use clear conditional phrasing: "If code references X, then do Y."
- Keep one transformation per file; use prerequisites when multiple files must run in sequence.
- Provide at least one concrete example (diff or before/after snippet) to improve transformation accuracy.
- Avoid ambiguous verbs like "improve" or "fix"—use explicit actions like replace, remove, update.
Test a custom upgrade instruction (one-time run)
Before running the instruction during an upgrade plan, validate it in isolation. This fast inner loop helps you refine detection and validate the code changes.
- In the Solution Explorer window, right-click the solution > Modernize.
- In chat, invoke the instruction using wording similar to the file name. For example, "replace Newtonsoft with System.Text.Json."
- Confirm in the chat window that Copilot retrieved the instruction file (it shows the text "Getting more instructions"). If it didn't, retry by using the key words from the file's name such as using the same verb (replace/update/remove) and nouns (Newtonsoft/System.Text.Json).
- Review the proposed changes (solution diffs, pending commits, or previewed modifications) to validate the custom upgrade instruction behaves as planned.
Validation tips
- If Copilot only updates package versions instead of performing a replacement, ensure the instruction explicitly says to remove or replace the old package.
- Use consistent naming so natural language activation matches. For example, the file name starts with
replace_and your chat request begins with "Replace ...". - Add missing code patterns you discover during testing as more examples to improve coverage.
Apply custom instructions during an upgrade
Use these steps to incorporate an existing custom upgrade instruction into an upgrade plan.
In the Solution Explorer window, right-click the solution > Modernize.
In the chat, choose
Upgrade to a newer version of .NET. Answer Copilot's questions until it generates the plan markdown file.Review the generated plan. Confirm whether the intended transformation is already present. If it only lists a version bump, your custom instruction wasn't yet applied.
In chat, explicitly reference the instruction using language similar to the file name. For example, "modify the plan using the custom instructions to replace Newtonsoft with System.Text.Json."
Wait for Copilot to confirm it retrieved the file. In chat, you see that it opened the markdown instruction file. If you don't see a reference, restate the request using the file's key verbs (replace, update, remove) and package names.
Review the plan file and verify that it includes the custom instruction's details.
Review package actions.
For example, when replacing Newtonsoft, the plan switches from a version upgrade to replacing or removing the package.
The plan may have started as version upgrade, as illustrated in the following image:
But then the plan changes to remove the package:
Review execution steps. Any new execution steps referencing the transformation appear under the plan's step list.
Tell Copilot to proceed with the upgrade once the plan reflects your custom instruction.
Monitor the Upgrade Progress Details. If Copilot pauses due to conflicts or compilation errors, resolve issues and instruct it to continue.
Tips for better activation
- Match the file's verb: if the file name uses replace, use that phrasing (not upgrade or fix).
- Keep one transformation per file for clarity and reuse; sequence multiple files by listing prerequisites in each file.
- Ask Copilot to modify the plan rather than manually editing; this reduces the risk of breaking dependency ordering.
- Avoid ambiguous requests like "improve the plan"; be explicit: "apply the replace_newtonsoft_with_system_text_json instructions."
Validate the applied changes
After the upgrade completes:
- Review the upgrade report for commits related to the custom instruction.
- Run your tests to ensure functional behavior remains correct.
- (Optional) Capture a diff example from the successful change and add it to the instruction file to strengthen future automation.
Clean up resources
If you created temporary instruction files for experimentation, remove or consolidate them to avoid overlapping transformations in future upgrades.