How to Set Up GitHub Copilot in Visual Studio (Step by Step)
Visual Studio is Microsoft's big IDE for C#, .NET and C++ on Windows. GitHub Copilot is built into Visual Studio 2026 and works in Visual Studio 2022 17.14 and later.
In short: update Visual Studio, sign in with a GitHub account that has Copilot (Free is fine), open View → GitHub Copilot Chat, and pick Ask or Agent mode.
Why Copilot in Visual Studio
Many .NET developers spend their whole day in Visual Studio. Copilot there knows your solution, your build errors and your tests, so it can fix and test code without you leaving the IDE.
What you need
- Visual Studio: 2026, or 2022 version 17.14 or later (Help → About Microsoft Visual Studio).
- GitHub account with Copilot: Copilot Free gives a monthly limit; paid plans give more.
- GitHub Copilot component: built into Visual Studio 2026; in 2022 check Extensions → Manage Extensions.
How setup flows
Install steps
- Open Visual Studio Installer and update to the latest version.
- Start Visual Studio. Go to Extensions → Manage Extensions. Search GitHub Copilot and install it if it is not already there.
- Sign in: Tools → Options → GitHub → Accounts, add your GitHub account (or use the Copilot badge at the top right).
- If you have no plan yet, sign up for Copilot Free when asked.
- Open a C# file and start typing. Grey suggestions appear. Press Tab to accept.
- Open chat: View → GitHub Copilot Chat.
Settings
- Modes: in the chat window, open the mode dropdown (shows Ask) and pick Agent for multi-step tasks.
- No Agent option? check Tools → Options → All Settings → GitHub → Copilot → Copilot Chat → Enable Agent mode in the chat pane, then restart.
- Tools: in Agent mode, the Tools icon controls which extra tools the agent can use.
- Model: pick a model in the chat window model list.
- Completions: turn them off or on from the Copilot badge menu.
Configuration
- Project rules: add
.github/copilot-instructions.mdin the repo root. - Keep connection strings and keys in User Secrets (
dotnet user-secrets) or environment variables, not in code.
# Rules for Copilot - .NET 10, C# latest, nullable enabled - Tests: xUnit, run with dotnet test - Use decimal for money - Never put connection strings in code
First task (5 minutes)
- Create a Class Library + xUnit test project (File → New → Project).
- In Copilot Chat (Ask) type: “Write a static C# method that adds GST to a price, using decimal, with xUnit tests.”
- Switch to Agent and say: “Add these files to the solution and run the tests.”
- Copilot asks before running terminal commands. Approve
dotnet test. - Review the changes, then click Keep or Undo.
- See the tested GST example in Code in C#/.NET using AI.
Quick quiz
1. Which Visual Studio versions support Copilot agent mode?
Visual Studio 2026, and 2022 version 17.14 or later.
2. Where do you sign in?
Tools → Options → GitHub → Accounts (or the Copilot badge).
3. Where do you open Copilot Chat?
View → GitHub Copilot Chat.
4. Agent option missing — what do you check?
The “Enable Agent mode in the chat pane” option, then restart.
Save tokens and money
Each agent prompt uses your Copilot allowance. Use Ask for questions and completions for small code. Use Agent only for multi-file tasks. Reference one file with # instead of the whole solution where you can.