Thursday, November 20, 2008

Case of duplicate VSMDI files – resolved?

If you are using VSMDI files, chances are you know what I am talking about. You get all your test lists defined, tests running, sun is shining and suddenly, out of nowhere second and then third VSMDI files get created.

The problem is pretty irritating one, as can be witnessed by some angry posts at MSDN. The problem also seems to be a complicated one because it can happen in multiple scenarios, and some of those scenarios are not readily reproducible. The reproducible scenarios are:

  • The solution with VSMDI file is not under version control, but VSMDI file is read-only. When Visual Studio needs to change it, new file (with suffix 1, 2 etc.) is created
  • The solution with VSMDI file is under version control, and VSMDI file is checked out with exclusive lock. When Visual Studio needs to change it, automatic check out is attempted and fails, and new file (with suffix 1, 2 etc.) is created

Other scenarios appear to involve Test List editor tool window, and not reproducible in 100% of cases.

So you’d say – that’s all very interesting, but how about fixing that? There are several ways to go about it.

First of all, scenarios involving read-only VSMDI files should be easily fixed (by removing r/o flag). In case of source controlled solution, there is KB support article 957358 detailing steps to avoid that.

Secondly, there is piece of advice that I really like (courtesy of Chris Menegay) – always modify VSMDI files by double-clicking the file in Solution Explorer (and not by using Test List editor etc.). From my experience, it appeared to work magically.

And lastly, most of these scenarios are fixed in Visual Studio 2008 SP1. If you have installed service pack, and still observe duplicated files appearing, folks at MS would be every interested to know about it. Leave a comment or drop me a line.

In next version of Visual Studio, VS 2010, the pain associated with VSMDI files should go away as there is a whole lot of changes in the way testing is done.

4 comments:

Coolweb said...

Thanks for these information.
Before reading your post I didn't understand why it occurs, and now yes. And effectively since I have VS2008 SP1 the problem disappears.

TFSDude said...

If you're stuck using a pre SP1 version of VS2008 or maybe 2005, I found that this was a great case for using the Forbidden Pattern Policy. Block checkins of any file named *.vsmdi#.

Rupert said...

Hi Eugene,

We all have VS2008 + SP1 and we all get this same problem daily. We have 16 different versions of the VSMDI file currently in the solution root folder.

Any idea how I go about stopping this happening? I can find nobody else on the web saying this is fixed in SP1.

Cheers, Rupert.

eugenez said...

Once you get into that problem, then you need to start off the clean slate.
Namely
1) Take a good copy of the file and rename it (file.vsmdi)
2) Delete all fileN.vsmdi from source control and solutions
3) Ensure there are no pending adds on any of file.vsmdi versions
4) Add the good copy to your solution and then check it in

Then you have a good starting point, and can investigate when the problem occurs. Following the advise in the post should help.