Visual Studio 2010: Deploying Content Types and Site Columns

When deploying a SharePoint 2010 solution, sometimes the automatic deployment with Visual Studio 2010 works and sometimes the following error message occurs:
“Error occurred in deployment step Activate Features” The content type with Id ‘xx’ defined in feature ‘yy’ was found in the current site collection or in a subsite.
I would expect, that the Retract action removes the whole solution and also the site columns. After executing the Retracting process the site columns are removed in SharePoint; but after redeploying it – the error still occurs :-(
So, I did some recherche on the net and found an explaination in the MSDN forum, answered by Mujahid Hasan (SDE, Visual Studio):
This problem is caused due to how SharePoint maintains it’s caches even after the solution (WSP) has been retracted. Your assumption is correct, the Field is actually retracted before the next deployment but due to a stale cache it fails on re-deployment. There are a couple of workarounds to fix this:

 

Workaround 1:
  • Right click on Project node in Solution explorer and click “Retract”. This will retract the Field.
  • Close VS. This will flush the stale cache.
  • Open the project in a new instance of VS and re-deploy the solution.
Workaround 2:

If closing VS after retract doesn’t solve the problem then a longer workaround is:
  • Redeploy the project -> This will show an error during feature activation.
  • Go to “Manage Site Features” under “Site Settings” in SharePoint UI in the browser.
  • Activate and then Deactivate the deployed feature which contains the Field.
  • Retract the Solution in VS i.e. right click on the Project node and click “Retract”.
  • Close VS. This will flush the stale cache.
  • Open the project in a new instance of VS and re-deploy the solution. This should work.
In my case the second workaround worked fine, but I think it’s quite uninteressting to do that work with every deployment.
So, I did the following:
I created a custom deployment process (project settings -> sharepoint) – without the activate feature step. So the deployment is finished with the Add Solution action and a activated the featue manually.
That’s working fine now.

Related Posts

  1. Why you should plan to migrate to Visual Studio 2010 already now!
  2. Content Type Publishing Link wird nicht angezeigt bei Subscribers
  3. Creating workflows for SharePoint 2010 with Office Visio 2010
  4. Compatiblity issue between SharePoint 2010 and Office 2007
  5. Nintex Workflow 2010

One Response to “Visual Studio 2010: Deploying Content Types and Site Columns”

  1. Eric Halsey 21 June 2011 at 23:24 #

    This worked!


Leave a Reply