Skip to main content

Posts

Showing posts with the label Visual Studio 2022

Testing your MCP server with Visual Studio HTTP Files

If you're building or testing Model Context Protocol (MCP) servers and you need a quick way to verify your endpoints are working correctly. Visual Studio's HTTP files ( .http ) provide an elegant, code-based approach to API testing What are Visual Studio HTTP files? HTTP files are plain text files with a .http or .rest extension that let you define and execute HTTP requests directly in your editor. They're supported in Visual Studio, Visual Studio Code (with the REST Client extension), and JetBrains IDEs. Think of them as executable documentation for your API. Why use HTTP files for MCP testing? The Model Context Protocol defines a JSON-RPC 2.0 interface for AI model interactions. Testing these endpoints traditionally meant using tools like Postman or curl commands, but HTTP files offer several advantages: Version control friendly : Store your test requests alongside your code Easy sharing : Team members can run the same tests instantly Fast iteration...

How to exclude specific content when using GitHub Copilot

GitHub Copilot is a powerful AI coding assistant and I couldn't miss it anymore. But there are times when you need to prevent it from accessing certain files or directories. Whether it's sensitive configuration files, proprietary code, or files that would add unnecessary noise to suggestions, exclusions help you maintain control over what Copilot sees. Why exclude content? You might want to exclude content from Copilot for several reasons: Security and privacy : Keep API keys, passwords, and other secrets away from AI processing Proprietary code : Protect sensitive business logic or algorithms Noise reduction : Exclude generated files, dependencies, or build artifacts that don't help with suggestions Performance : Reduce the context window size for faster suggestions Reasons enough to spend some time configuring your content exclusions. GitHub Copilot content exclusion settings Content exclusion is a Copilot Business or Enterprise feature and can...

I love it when a plan comes together

I love it when a plan comes together A quote by Colonel John “Hannibal” Smith, the cigar-chomping leader of The A-Team , a hit 1980s TV series and one of my childhood memories. The lesson to be learned from Hannibal, is that planning is important to succeed.  With the newly introduced ‘Planning mode’, planning also finds its place in our AI assisted development workflows inside Visual Studio. What is Planning Mode? Planning mode extends GitHub Copilot's Agent Mode capabilities to handle larger, multi-step coding tasks with a structured approach. Instead of jumping straight into code generation, Planning mode creates a detailed execution plan that includes: A clear breakdown of tasks to be completed Files that need to be edited Context about the approach Copilot will take Checkpoints for transparency and control These plans are stored as Markdown files with task lists, giving you complete visibility into what Copilot intends to do before it starts mak...

Use request chaining in HTTP files

By default every request inside your HTTP file is independent from any other request. But what if you want to use the output of one request as the input of another request? This is exactly what you can achieve using request variables. Creating resources with dependencies As an example I created a new ProjectController that we will use to: Create a new project Use the returned project id to create and assign a new task to this project I updated the http file with a new request to create the project. Notice that I included a createProject variable to name the request. I can now use this createProject variable in other requests. In our example I extract the project id value from the response: The following table describes the syntax in more details: Element Description requestVarName ( login in this case ) Request Variable which is being referenced. response|request Whether the value will be...

Use shared variables in HTTP files

Yesterday I explained how you can introduce environment specific variables when using .http files in Visual Studio. But now we need to repeat these variables for every environment even when they stay the same. In this post I show how to avoid this by introducing the special $shared environment. The $shared environment Visual Studio 2022 version 17.12 introduced the $shared environment, which is perfect for variables that should be available across all environments: You can now use these shared variables no matter which environment you have selected: More information Use .http files in Visual Studio 2022 | Microsoft Learn

Use environment specific variables in HTTP files

HTTP files provide a convenient way to test your API’s inside Visual Studio. In this post we'll look at a specific feature; the usage of environment-specific variables that let you seamlessly switch between environments without modifying your request files. Getting started with .http files Before diving into environment variables, let's understand the basics. When you create an ASP.NET Core project in Visual Studio 2022, you'll often find a .http file already in your solution. Here's a simple example: Variables are defined with @variableName = value and referenced using {{variableName}} . The ### delimiter separates multiple requests in a single file. Creating environment files The real power comes when you externalize these variables into environment files. Visual Studio supports two types of environment files: 1. http-client.env.json (Shared) This file contains environment configurations that are shared across your team and typically committed to sourc...

GitHub Copilot walkthrough

Although GitHub Copilot is now available for some time in VSCode, Visual Studio and almost every other popular IDE, for a lot of people it still feels new and unfamiliar. If you are one of these people I have some good news for you; the Visual Studio team got you covered. Because a GitHub Copilot walkthrough was added to Visual Studio. This walkthrough is an interactive guide that helps you to understand and use GitHub Copilot’s features step-by-step. To active the walkthrough, click on the GitHub Copilot icon in the top right corner and choose GitHub Copilot Walkthrough from the context menu: This will give you a general introduction on what GitHub Copilot has to offer:   To be honest I am a little bit disappointed in what this walkthrough shows. My hope was that it would walk you through a set of scenarios, showing how GitHub Copilot can help in each of these cases. Maybe something for a next Visual Studio Release? More information Agent mode for every developer...

Giving Copilot Agent in Visual Studio a try

After using the GitHub Copilot Agent mode for some time in VS Code, I finally found some time to give it a try in Visual Studio. Agent mode got introduced as part of the 17.14 release so if you are still using an older Visual Studio version, please update first. Remark: Other interesting AI features in the same release are Next Edit Suggestions and AI comment generation . Let’s dive in! Open Visual Studio and go to the GitHub Copilot Chat window :   Click on the dropdown icon next to Ask and choose Agent : Remark: Notice that the Edits feature has disappeared. So you only have Ask or Agent . I don’t know if the feature is still there, but at least I couldn’t find it… Now we can ask the agent to perform specific tasks or let it figure out a solution based on a PRD (Product Requirement Document) or similar you’ve provided. So far so good. The not-so-secret superpower of agents is that they are not limited to your IDE but can interact with the outsid...

Untrusted GIT repositories in Visual Studio

For security reasons I am switching to a different account on my development machine. After adding this new account to Windows and setting up the Visual Studio configuration for this new account, I thought I was good to go. So I opened a first solution inside my fresh Visual Studio instance. Everything looked OK at first sight, but then I noticed a small warning message at the right bottom corner of my Visual Studio: And when I took a look at the Git Changes window, no changes were shown:   What is going on? Starting from Git v2.35.2 , Git now checks for ownership of the folder trying to ensure that the folder you are using Git in has the same user as the owner as your current user account. As the original Git repo(and corresponding Windows folders) was created using a different account, Git considers this repository as unsafe. This check was introduced in Git to tackle a security issue which allows parent repositories directories to override permissions of child reposi...

Speed up your Git experience by enabling the commit graph algorithm

While working in Visual Studio today I noticed a message appear at the top my idea. The message stated the following: Speed up your git experience in Visual Studio by enabling the git commit graph algorithm. No idea what that exactly means but that sounds promising… so let’s find out Why this commit graph algorithm? Git repositories can become sluggish as they grow in size and complexity. If you've ever waited impatiently for git log to load or noticed that branch operations take longer than they should, you're not alone. Recently, Git introduced a powerful feature that can dramatically improve performance: the commit graph algorithm. The commit graph is a data structure that Git uses to store precomputed information about your repository's commit history. Instead of traversing the entire commit tree every time you run commands like git log , git merge-base , or git show-branch , Git can use this precomputed graph to answer queries much faster. Think of it ...

Visual Studio 2022 – GitHub Copilot Vision support

I talked about how you could start using Vision in GitHub Code before. At that time, it was however limited to VS Code. With the latest release of Visual Studio 2022 (17.13), this feature is now also available inside Visual Studio. Important: As this feature is in preview, it may not be available to all users. Due to the gradual rollout, you may not see the option to attach images in chat immediately. Get Started If this feature is available for you, a new paperclip icon appears in your chat window:   Now you can either directly paste an image from your clipboard or use the paperclip icon to upload an image: Once uploaded you can add your prompt and send everything to Copilot. Copilot will then analyze the image and use it as additional context while generating a response.   Nice! More information Adding vision to Github Copilot

Disable NuGet Central Package Management for specific projects

Centralized Package Management is a NuGet feature that allows you to manage NuGet package dependencies for multiple projects from a single location. This is particularly useful for large solutions with many projects, as it simplifies the process of keeping package versions consistent across the entire solution. After enabling Central Package Management for an existing solution and committing those changes, one of our build pipelines started to fail. When we took a look at the logs we encountered the following error message: ##[error]The nuget command failed with exit code(1) and error(NU1008: Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: Dapper;Microsoft.Data.SqlClient;Microsoft.Extensions.Configuration;Microsoft.Extensions.Configuration.Binder;Microsoft.Extensions.Configuration.Json;Microsoft.Extensions.Http;Spectre.Console;Spectre.Console.Json. What is happening? The reason we...

GitHub Copilot–Code reviews

The integration of Copilot inside Visual Studio and VS Code keeps expanding. With the 17.13 release of Visual Studio, GitHub Copilot can now review your changes before you commit them. It will examine your changes and provide suggestions inline. Enabling code reviews As this is still a preview feature, you first need to have some feature flags turned on: • Tools > Options > Preview Features > Pull Request Comments   • Tools > Options > GitHub > Copilot > Source Control Integration > Enable Git preview features.    Using code reviews Now when you do some changes, you can ask GitHub Copilot to review them before they are committed. Therefore, go to the Git Changes window and click on the small Review changes with Copilot icon: If the Copilot reviewer has comments, you get a message: You can click on the link to go to the specific comment: Nice!

GitHub Copilot–Code referencing

One of the risks of using tools like GitHub Copilot, is that we start to over rely on these tools and that we blindly accept any suggestion or code change it wants to make. This is not so different than what we had before with the ‘copy-paste’ programmer who just copied the first snippet he could find online. But with the integration of AI inside our IDE’s, it has become a lot easier to just accept these changes without questioning the quality of the suggestion or its source, especially as these tools can generate bigger and bigger code blocks. This is where Code Referencing can help. It introduces a filter that detects when code suggestions match public code on GitHub, providing you with valuable context to make more informed decisions about the code you are about to incorporate into your projects. Let’s give it a try! Enable Code Referencing Before we can use this feature, we have to check if it is enabled. In the upper-right corner of any page on GitHub, click your prof...

Extend Github Copilot capabilities through the Copilot Marketplace

I already talked about custom instructions in Github Copilot as a way to tweak Github Copilot. Today I want to show another way to extend the capabilities of your Copilot; Copilot Extensions, a set of third party tools, services, and data available (in preview) through the Copilot marketplace :     What are Copilot Extensions? Copilot extensions are third-party tools, services, and data integrations that enhance the functionality of GitHub Copilot. They allow you to leverage additional features and capabilities directly within your coding environment. Whether you need help with code quality, security, documentation, or project management, there's likely a Copilot extension that can assist you. At the moment of writing this post Copilot Extensions is still in preview and the list of available extension is still limited. Extension usage is not possible in every IDE. Here is the list of supported IDEs:   How to get started with Copilot Extensions Getting star...