Both X and X contain a file that deploys to the same package location

Ran into this error today. It consumed an embarrassing amount of time to fix. I have been close to chucking computers out the window before, but today was a new record.

So for some reason when I tried to publish or deploy my SharePoint app project I was greeted with:

—— Build started: Project: AddinTest, Configuration: Debug Any CPU ——
C:\Users\[REDACTED]\Source\Workspaces\SharePoint Test App\AddinTest\AddinTest\Features\Feature1\Feature1.feature : error : The following file can not be found: “C:\Users\[REDACTED]\Source\Workspaces\SharePoint Test App\AddinTest\AddinTest\Content\bootstrap-datetimepicker-build.less”.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========


Okay so it can’t find a file. Odd considering I haven’t touch the project, but stranger things have happened. Upon inspection of the solution tree I can confirm that it is indeed not there. My natural instinct is to look at the Feature file and see what it is including, but it doesn’t include the file either.

2016-03-23 18_35_26-AddinTest - Microsoft Visual Studio (Administrator)

I know I’m not using that file, I’ve no idea why it’s looking for it so I poke around the Elements file to see if it’s referencing it there and if it is, simply remove it. However, no. It’s not there. I struggle to figure out why my project is looking for this file, so instead I decide to just create it in the Content folder. A blank version that is, simply to satisfy the build so that I can deploy and test my code.

2016-03-23 18_39_35-AddinTest - Microsoft Visual Studio (Administrator)

The file is added now, so in theory the project should compile and deploy without error. Of course it doesn’t. Life is never that easy. New error.

C:\Users\[REDACTED]\Source\Workspaces\SharePoint Test App\AddinTest\AddinTest\Package\Package.package : error SPT16: Both “Content” and “Content” contain a file that deploys to the same Package location: AddinTest_Feature1\Content\bootstrap-datetimepicker-build.less

WHAT!? First it complained that it didn’t have the file, and now it is giving out because it is trying to copy over two files of the same name? What is even more annoying is that Visual Studio has decided to crawl today. Every click inside the application takes around 2-5 seconds to register.

I dig and dig and dig. I can’t see where these files are being referenced. The Elements.xml files appear to correspond to what I see in front of me – only one version of the file.

After a while I eventually click on the icon to show all files. This has saved my ass before as it can highlight conflicting items that are not included in the project. At first glance it didn’t really bring up anything new in Content folder, as I was expecting to see a grayed out file/folder icon, but upon closer inspection a new file did appear.

2016-03-23 18_47_10-AddinTest - Microsoft Visual Studio (Administrator)

SharePointProjectItem.spdata, you bastard.

2016-03-23 18_48_52-AddinTest - Microsoft Visual Studio (Administrator)

So the files that are being copied across as referenced in the .spdata file of the folder, and this file is not visible by default.

So I deleted these two lines, and removed the blank file that I created in the folder and now the build and deploy worked.

2016-03-23 18_53_42-AddinTest - Microsoft Visual Studio (Administrator)

Frustrating few hours.