Visual Studio – How to use conditional breakpoints

Breakpoints cause execution to pause when you’re running the debugger. This is referred to as breaking, and it allows you to look at the current state of things for debugging purposes. In some cases, you may want to use a conditional breakpoint to only break execution when certain conditions are met (ex: break when name … Read more

Visual Studio project templates without minimal API and top-level statement

Devs want the option to create new projects in Visual Studio without all of the minimalist stuff that was recently added (top-level statement, minimal API). At the very least, these features should be optional instead of being the default without a way to opt-out (to be fair, minimal API is optional). What I typically do … Read more

How to make the build Up-to-date Check ignore your text template generated output

When you build a project / solution in Visual Studio, the Up-to-date Check feature will determine if the project needs a full rebuild or if it’s already up-to-date. There are many factors it checks – mainly, did the source code change since last time? Surprisingly, one thing that triggers a full rebuild is text template … Read more

Microsoft.TextTemplating.targets was not imported due to the file not existing

Problem You have a project that is using text templating and you’re upgrading to a new version of Visual Studio. When you open the project, you get error messages about not being able to import the Microsoft.TextTemplating.targets project: Project “…\v16.0\TextTemplating\Microsoft.TextTemplating.targets” was not imported by “…SomeProject.csproj” at (7,3), due to the file not existing. The error … Read more

How to turn off IntelliCode completion suggestions in Visual Studio

Visual Studio 2022 has a feature called IntelliCode completions that suggests full line completions as you’re typing. It’s enabled by default. It shows a greyed out suggestion based on what it thinks you’re going to want. This is different from the regular IntelliSense modal popup that shows below the line you’re typing. Here’s what it … Read more

Quick way to create a unit test project in Visual Studio

You don’t need to manually create a unit test project (through the UI or through the command line). Instead, you can can use the Create Unit Tests command in Visual Studio to generate a unit test project, add it to the solution, and wire up a test stub all at once. Note: This approach can … Read more

C# – IDE0060: Remove unused parameter

If you have a method with a parameter, and that parameter is not used in the method, then you’ll get the IDE0060 message telling you to remove the unused parameter. Here’s an example of code that would trigger this message: The encrypt parameter isn’t being used in the Send() method, triggering the IDE0060 message: IDE0060 … Read more

System.Data.SqlClient is missing in a .NET Core project

When you create a new project in .NET Core, and you try to use a class from ADO.NET, such as SqlConnection, you’ll get missing reference errors. For example, your code might look something like this, and it’ll have red-squiggly lines under SqlConnection: In the past, you’d simply add a reference to System.Data.SqlClient, like this: To … Read more

.NET – Copy files to a specified directory after the build

The simplest way to copy files post-build in a .NET project is to use the MSBuild Copy Task in the .csproj file, like this: Note: I’m using VS2019. My project is called NotesAPI. When I build, it logs the following messages: It copied the following build files into C:\Build\NotesAPI: NotesAPI.dll NotesAPI.pdb In this article, I’ll … Read more