Visual Studio: Duplicate Resources Error While Creating Database Unit Tests
Here is a little 'feature' I hit while building some database unit tests in Visual Studio.
The symptom is you get a message that says something along the lines of:
The item "obj\Debug\DbTestPrj.testName.resources" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
After digging around and examining all of the project files, I could not find any configuration that was specifying the resource more than once. I did the first thing most people will do and did an Internet search for the problem. I never found a good solution in any of the search results, so I did more digging in the code and project files. Eventually I found the problem by doing a search of my entire disk for a fragment of the testName. This is when I was able to figure out what happened.
While I was building my project, in the solution explorer, I did a copy/paste of one of the tests and renamed the file. Under the covers, the class name was still the same name that was used in the file I copied. This is somewhat hidden from you as a user unless you do a "view code" on the test case.
Once you find this problem, its pretty trivial to fix. Manually change the name of the class and the problem goes away.
In hind site, this is kind of an 'Oh doh' type problem. I don't normally expect the name of the class to change when I change the file name, but since the class is somewhat hidden in the UI, you forget about this little detail when you do a copy/paste operation.
I am posting this because I spent a good hour trying to figure out what the heck was going on and didn't find anything recommending a way to fix it. Hopefully this helps out some and save you some time.