Using a common intermediate and output directory for your solution

By default each project in a VS solution has its output directory set to bin and its intermediate output directory to obj subdirectories of each project directory. If you’re using version control, you will find bin and obj directories scattered all over your tree, and although you can easily clean them all up with git…



I published a tool to print out the evaluated values of properties and items in an MSBuild project: It is available on Chocolatey: cinst MSBuildDumper Usage: MSBuildDumper MyProject.csproj > props.txt I’ve blogged about this earlier: but now I decided to actually put it on GitHub and publish it on Chocolatey so that it…


How to investigate Rebuilding in Visual Studio when nothing has changed

In some managed projects there’s this unfortunate behavior: you press F5 in VS, run your app, stop, then press F5 again and it says “Building…”. Why is it building when nothing has changed? Or you change something in one project and multiple seemingly independent projects are being rebuilt as a result. This slows you down,…


Get most duplicated strings from a heap dump using ClrMD

ClrMD is an awesome managed API to inspect managed processes and dump files. To use it, just add a NuGet reference to Microsoft.Diagnostics.Runtime. When loading a dump, be sure to have the mscordacwks.dll from the machine where the dump was taken. Also make sure that your program that uses ClrMD is the same platform (32/64-bit)…


sn.exe cheat sheet

I don’t find sn.exe command line arguments particularly intuitive, and the fact they’re case sensitive doesn’t exactly put you in the pit of success either. Also, it turns out there are two kinds of .snk files. One kind is 596 bytes by default and contains a key pair (private and public key). The other kind…


Creating an instance of an open generic type without specifying a type argument

My fellow Roslyn tester @vreshetnikov has found not one, but two ways to do the impossible: 1: using System; class Program {     static void Main()     {         var open = Enum.ToObject(typeof(C<>.E), 0);         Console.WriteLine(open.GetType());     } } class C<T> {     public enum E { } } 2: using System; class Program {     static void Main()     {         Action<C<int>.E> a = M;         var open = a.Method.GetGenericMethodDefinition().GetParameters()[0].DefaultValue;         Console.WriteLine(open.GetType());     }     static void M<T>(C<T>.E e = 0) { } } class C<T> {     public enum E { } }


Saving Regedit Favorites in a .reg file

Regedit.exe has a useful feature – Favorites menu, you can add an often used registry location to favorites to quickly expand to it in the tree view. But did you know that favorites themselves are stored in registry and so you can have a RegeditFavorites.reg that you run to quickly fill the Favorites menu with…


Registry keys to configure Watson and automatically save full dumps locally

You might have noticed that after installing Visual Studio the behavior of crashing programs changes – instead of the standard crash dialog you get the Visual Studio Just-In-Time Debugger: AeDebug The behavior of handling crashing programs can be controlled in the registry: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug] "Debugger"="\"C:\\windows\\system32\\vsjitdebugger.exe\" -p %ld -e %ld" "Auto"="1"…


Circular assembly references in the .NET framework

It was a surprise to me when I discovered that a lot of assemblies in the .NET BCL reference each other in a circular manner: Cycles in the reference graph are in red. Apparently there is special MSBuild magic used when compiling these assemblies. My guess would be that proper factoring of the assemblies into…


Dump MSBuild properties and items for a project

Sometimes when you’re reading a .csproj file you encounter properties like $(TargetDir) and wonder what directory does this property evaluate to when the project is compiled. Of course you can use heavy machinery like the MSBuild debugger, but sometimes a simpler tool can suffice. Here’s what I wrote in literally 5 minutes: using System; using…