Thursday, March 11, 2010

Multiple vsmdi files with VS 2008: the path to freedom

If you use a combination of Visual Studio 2008, MSTest and TFS, you've probably come across this problem at some point. Your solution folder is suddenly full of vsmdi files:







You may have worked out that Visual Studio generates a vsmdi file the first time you run unit tests with MSTest. This file basically stores the list of tests that will be ignored.

The problem comes when multiple developers are running tests at the same time – rather than checking out the same vsmdi file, your Visual Studio will "helpfully" create a new one, adding it to source control.

The best solution seems to be to exclude these files from source control altogether:

1) Delete all .vsmdi files from both source control and your local solution folder

2) Open the solution in Visual Studio

3) Open Test View (Test > Windows) and toggle the "enabled" property of a random test - this will force it to create a new .vsmdi file









4) In Solution Explorer, select the new vsmdi file (should be under Solution Items), right-click it and Undo Pending Changes

5) With the file still selected, click File > Source Control > Exclude [file] from Source Control

6) Check in

As long as everyone now "gets latest", you should each end up with a single writeable vsmdi.