Be aware of copy/paste

Problem

You are working with a SharePoint 2010 solution inside VS2010 to add some site columns (could be any type of SPI but maybe most common with site columns).

You have added your first column like in the picture below:

The second column you are about to add is more or less the same so you decide to do a copy/paste (to save some time avoiding to use “add new item”) ending up with something like in the next picture:

Perform a rename of the item to column 2 and change the ID (and what other stuff you have in the element manifest).

Deploying (or packaging) then shows you this annoying error:

For the search indexer:“{Site Column Name}” and “{Site Column Name}” contain a file that deploys to the same Package location: {Project Name}\{Site Column Name}\Elements.xml

Say What?

Are column 1 and column 2 containing a file that references the same location…?

The solution

If you click on the little button in your project to show all the files and open up the .spdata file that belongs to column 2´s SPI you will see that the target (or location) still references column 1. This is a result of the copy/paste operation.

So just change that so it references the column 2 instead (or whatever name you have) and your SharePoint solution again deploys/packages as expected.

UPDATE:

After getting a comment from a colleague of mine, Rikard Uppström, who informed me that the same can be done by selecting the elements.xml file and pressing F4 which brings up the properties.
And there you go:

You can change the path/location from there and I guess that will update the .spdata file…GREAT!
Let´s not make it more complicated than it really is…(but I guess it can be nice to know why and how this works behind the scenes)

, ,

  1. #1 by Rikard Uppström on February 22, 2011 - 19:30

    I think you can also modify the elements deployment location by marking it, pressing F4 to bring up its’ properties and then modify. Or am I misunderstanding something?

    • #2 by Johan Leino on February 22, 2011 - 20:12

      You are correct sir/colleague…why make it more complicated than it is. I´ll update the post! Thx

  2. #3 by Garrett Costello on March 1, 2011 - 01:16

    I just want to mention I am all new to weblog and certainly liked you’re website. More than likely I’m planning to bookmark your blog . You actually have awesome articles. Bless you for revealing your website.

  3. #4 by Mortgage Interest Tax Deduction on May 18, 2011 - 00:55

    some truly superb posts on this site, appreciate it for contribution.

  1. Be aware of copy/paste

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: