0

What I did:

  1. Create an Empty SharePoint Project
  2. Create a simple Text Field
  3. Test - (re)deployment and retraction of Solution are causing no problems
  4. Create Content Type which consists of this one simple Text Field
  5. Test - still no problem with (re)deployment and retraction
  6. Create a List Definition and Instance which now uses the created Content Type

Now comes the problem. Deployment and retraction work for the first time but as soon as I try to redeploy the Solution SharePoint is able to delete the List Definition and Instance but not the Content Type. When I try to delete the Content Type via the Web UI I get an error that this Content Type belongs to an application Feature. Disabling the Feature doesn't remove the Content Type. Deleteting the List which uses the Content Type (and making sure the Content Type had an Usage of 0; also deleting the List from Past Bin/ SiteCollection Paste Bin) didn't help. Googling half the day (reading here, here and here) and trying different things I was able to delete the Content Type after setting "IsFromFeature" in the Content Database (I know this should be the last approach). After deleting the Content Type the next deployment works without problems but when I retract the Solution and try to redeploy it, I get the old behaviour.

Did I do anything wrong with the order of deployment? How can safely deploy Fields, Content Types and List Definitions/Instances without being unable to redeploy them?

2

I think I had success with this by using the Overwrite=True attribute (https://msdn.microsoft.com/en-us/library/office/aa544268.aspx).

Also I believe once the content type is in use in a list instance it might be blocked from being removed. Try deleting the instance and then clearing it from both the first stage and second stage recycle bin then deactivating your feature. I think you should then see the content type successfully removed.

All in all I struggled with using this type of declarative provisioning and found enough hits on the web where people suggested using either part of full programmatic deployment instead.

This means using the SharePoint object model and writing code to deploy your content types, lists etc. So far I have been able to do everything except create a list definition using code.

The benefit is (as best I understand it) that my artifacts are not tied to physical schema.xml files and deleting the feature has no effect on the created items.

If you decide to go down this path I could provide the provisioning code that I have used so far.

  • The first feature I created used schemas, it was the last feature that did, and every other feature after used feature activation code to create lists and attach content types, etc. – Eric Alexander Feb 12 '15 at 18:55
  • I'm not sure what state you are in now. I use both sharepoint manager 2013 which let's you browse all objects and properties and the feature admin tool featureadmin.codeplex.com) to debug this stuff. – Satyrical Feb 13 '15 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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