Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a List Instance in Visual Studio. However, every time I deploy the solution, Visual Studio says there is already a list instance with the same URL on the site collection and it needs to delete it first before deploying the new one.

I would like to know if there is a way to upgrade the list instance so that the only things changed when I deploy the list instance will be whatever is new or different compared to the current state of the list instance on the site collection. I would like to maintain all the items in the list as well as the columns and other properties unless they are explicitly changed in Visual Studio.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You should use the new Feature upgrade functionality available in SP2010. You can edit the feature by selecting the Manifest Tab and clicking on Edit Options at the bottom of the screen. Then you can add an UpgradeActions node like this:

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Version="1.0.0.0">
  <UpgradeActions>
    <VersionRange BeginVersion="0.0.0.0" EndVersion="1.0.0.0">
      <ApplyElementManifests>
        <ElementManifest Location="AdditionalFields\Elements.xml" />
      </ApplyElementManifests>
    </VersionRange>
  </UpgradeActions>
</Feature>

You need to give your feature a version number and use that for the EndVersion. In the Elements.xml only include the new fields that you want to add.

After building your project, use Powershell (Update-SPSolution) to upgrade your solution. Unfortunately, you need to execute code to do the actual upgrade on your feature.

But, this tool should help you with that part: http://spfeatureupgrade.codeplex.com/

share|improve this answer
    
That may be a little bit frustrating to change the version everytime you deploy from VS2010. On my side, everytime I deploy, the previous version is been retracted and re-deploy without changing the version and it kept the configuration that were previously set –  Gabriel Mongeon May 5 '11 at 13:38
    
Thank you for your reponse Laurie. I am very new to SharePoint and tried to implement this xml but it doesn't seem to be working. Every time I package my solution, I increment Version and EndVersion by 1 so they match. Is this correct? I also made a few column name changes in the Schema.xml file but I do not see these changes after running Update-SPSolution. Do I need to make the changes in the AdditionalFields/Elements.xml file? Because I currently have that line commented out. And what do you mean by needing code to execute an actual upgrade on the feature? Thanks! –  Meyer Denney May 5 '11 at 18:36
    
Yes, you need put your new fields in the Elements.xml. The part that you are upgrading is just the additional fields. If you go to the codeplex link mentioned above, there is a link there to a 5 part series on feature upgrading. All that being said, if you are only deploying this to your own dev environment, then you don't need to worry about losing data in your list. So, as Gabriel wrote, you can just retract your solution and redeploy. It's fine to wipe out the existing list and start over. –  Laurie May 5 '11 at 19:31
    
Could you give me a small example of how to add a new field in the Elements.xml file? I couldn't figure out the correct syntax and the codeplex project couldn't load an assembly properly. Thanks again for all your help Laurie :) Also, was I correct in incrementing the Version as well as the EndVersion numbers so that they go up by one each time I re-package and that they should always be equal? –  Meyer Denney May 5 '11 at 19:40
1  
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="schemas.microsoft.com/sharepoint/">; <Field ID="{647DC46C-DC26-4DB0-A97C-7C21E4362A96}" Type="Choice" Name="Muppet"> <CHOICES> <CHOICE>Kermit</CHOICE> <CHOICE>Fozzy Bear</CHOICE> <CHOICE>Miss Piggy</CHOICE> </CHOICES> </Field> </Elements> The feature will be upgraded if the current version number >= BeginVersion and < EndVersion. –  Laurie May 6 '11 at 5:41

By default, you should see a Deployment Conflicts dialog box when you redeploy your solution to your development computer; this should have warned you that your existing list instance would be overwritten. To change this behavior, select the List Instance in Solution Explorer, and then change the Deployment Conflict Resolution property (in the Properties window) to None. If this property is set to Automatic, then existing items will be automatically overwritten without the dialog

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.