C# – Duplicate ‘AssemblyVersion’ attribute

Problem You’re trying to add the AssemblyVersion attribute to your project, like this: And you get the following compiler errors: Error CS0579 Duplicate ‘AssemblyVersion’ attribute Error CS0579 Duplicate ‘AssemblyFileVersion’ attribute But you don’t see these attributes anywhere else in your project. Solution The problem is Visual Studio auto-generates the assembly info by default. To turn … Read more C# – Duplicate ‘AssemblyVersion’ attribute

How to generate XML documentation and include it in a nuget package

XML documentation comments serve two purposes: Intellisense shows the comments to devs using your code. You can generate a documentation file and include it in your build and nuget package. In this article I’ll show how to automatically generate an XML documentation file and how to include it in a nuget package. 1 – Write … Read more How to generate XML documentation and include it in a nuget package

C# – Use Assert.ThrowsException instead of ExpectedException attribute

If you’re using the built-in MSTest unit testing framework, you may be used to the old way of asserting exceptions by using the [ExpectedException] attribute. The following example illustrates one of the key problems with this approach: The ArgumentNullException is being thrown, so the test passes. However, the exception is being thrown in the arrange … Read more C# – Use Assert.ThrowsException instead of ExpectedException attribute

Class Diagrams missing in Visual Studio 2019

Problem The Class Diagram item is missing in Visual Studio 2019. Solution For some reason this is not installed by default in Visual Studio 2019, so we simply need to install it. 1. In Visual Studio click Tools > Get Tools and Features… 2. Close Visual Studio. 3. In Visual Studio Installer: Click Individual components … Read more Class Diagrams missing in Visual Studio 2019

Visual Studio 2019: MSTest unit tests are not running in Test Explorer

Problem I have a unit test project in Visual Studio 2019. When I click Run All Tests, none of the tests run. I looked in the Tests output window and saw a message that says: Test project does not reference any .NET NuGet Adapter. Test discovery or execution might not work for this project. It’s … Read more Visual Studio 2019: MSTest unit tests are not running in Test Explorer

Visual Studio 2019 – All references say referenced component could not be found

Problem When I open a C# project in Visual Studio 2019, none of the references are loading. In the error list it says: The referenced component could not be found This usually means you need to restore the Nuget Package. In this case, it’s even showing this for .NET Framework references – such as System.Core. … Read more Visual Studio 2019 – All references say referenced component could not be found

Auto-increment build numbers in Visual Studio

You need to auto-increment your build numbers in order to easily tell which code you’re working with. In this article I’ll explain how to auto-increment your build numbers in Visual Studio. I’ll be using text templating to generate the Assembly Version. 1 – Choose a versioning scheme I’m going to be using the version scheme: … Read more Auto-increment build numbers in Visual Studio

Starting the Visual Studio debugger when Attach to Process doesn’t work

Problem You’re trying to debug a program with Visual Studio but Attach to Process does not work. Most likely you’re loading your code through some third-party process (like Excel), and when you try to use Attach to Process it simply doesn’t work. Solution Instead of trying to use Attach to Process, you can launch a … Read more Starting the Visual Studio debugger when Attach to Process doesn’t work