If I’m frequently copying, pasting, and deleting SharePoint items from my Visual Studio 2010 project, I can sometimes confuse Visual Studio. When this happens, I try to deploy my solution package and I get an error like
Both ‘CustomDocuments’ and ‘CustomDocuments’ contain a file that deploys to the same Package location: CustomDocumentsListInstance\CustomDocuments\Elements.xml
This is confusing since I only see one file listed. Why is it saying the same item is trying to deploy to the same location, as if it were two different files? Turns out that when you add an item to a SharePoint item (sucn as a module, list definition, list instance, etc.) it adds a reference to it to the .spdata file in that folder. (If you can’t see the spdata file, click on the “Show all files” button in the toolbar of your Solution Explorer.) You’ll most likely find duplicate entries in there, or the wrong folder name if you changed the folder name to something else. Make your changes to the spdata item and your solution should package properly.