Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2 · SETUP

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

WHY

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

WHAT
  • 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

1 · Update VS Visual Studio Installer 2 · Check Copilot Extensions → Manage Extensions 3 · Sign in Tools → Options → GitHub → Accounts 4 · Open chat View → GitHub Copilot Chat 5 · Ask / Agent review, Keep or Undo

Install steps

HOW
  1. Open Visual Studio Installer and update to the latest version.
  2. Start Visual Studio. Go to Extensions → Manage Extensions. Search GitHub Copilot and install it if it is not already there.
  3. Sign in: Tools → Options → GitHub → Accounts, add your GitHub account (or use the Copilot badge at the top right).
  4. If you have no plan yet, sign up for Copilot Free when asked.
  5. Open a C# file and start typing. Grey suggestions appear. Press Tab to accept.
  6. Open chat: View → GitHub Copilot Chat.

Settings

  1. Modes: in the chat window, open the mode dropdown (shows Ask) and pick Agent for multi-step tasks.
  2. No Agent option? check Tools → Options → All Settings → GitHub → Copilot → Copilot Chat → Enable Agent mode in the chat pane, then restart.
  3. Tools: in Agent mode, the Tools icon controls which extra tools the agent can use.
  4. Model: pick a model in the chat window model list.
  5. Completions: turn them off or on from the Copilot badge menu.

Configuration

  1. Project rules: add .github/copilot-instructions.md in the repo root.
  2. Keep connection strings and keys in User Secrets (dotnet user-secrets) or environment variables, not in code.
.github/copilot-instructions.md
# 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)

  1. Create a Class Library + xUnit test project (File → New → Project).
  2. In Copilot Chat (Ask) type: “Write a static C# method that adds GST to a price, using decimal, with xUnit tests.”
  3. Switch to Agent and say: “Add these files to the solution and run the tests.”
  4. Copilot asks before running terminal commands. Approve dotnet test.
  5. Review the changes, then click Keep or Undo.
  6. See the tested GST example in Code in C#/.NET using AI.
Rule: agent mode can run commands and edit many files. Commit your work to Git first, so you can undo easily.

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

SMART AI USE

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.

Save these cards

INTERVIEW CARDAI Coding

How to set up Copilot in Visual Studio?

Update VS (2026 or 2022 17.14+).
Sign in with GitHub → View → GitHub Copilot Chat.
Ravindra Bagale · ravindrabagale.com/ai-coding
COMPARISON CARDAI Coding

Ask vs Agent in Visual Studio

Ask: one answer, you apply it.
Agent: edits files, runs build/tests, iterates.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

Copilot in VS in 4

Update → Sign in → Tab to accept.
Chat → Ask or Agent.
Keep or Undo changes.
Ravindra Bagale · ravindrabagale.com/ai-coding