2014-10-29

Visual Studio 2013 Cannot Deploy Content Type Updates

After spending 10+ hours trying to figure out why content types included in my wsp cannot be deployed using Visual Studio 2013 deploy without recreating SP site I must say I am disappointed with my findings. Content types cannot be removed from SP site by using Visual Studio 2013 Retract command. My colleague can successfully deploy (and retract) content types using Visual Studio 2012, so I decided to look inside what is really happening under the hood.

Apparently, both Visual Studio versions, 2012 and 2013, are using Microsoft.VisualStudio.SharePoint.Commands.Implementation.V5.dll to deploy and retract SharePoint solutions to SharePoint sites. But the big difference between the two is that VS 2012 implements Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeatures in a way so that it calls SPFeatureCollection.Remove method with force argument set to true which causes a call to stored procedure proc_DeactivateContentTypeInScope with SQL parameter @IsDeactivatingFeature set to 2. When this parameter is set to 2 then stored procedure skips a call to another stored procedure named proc_IsContentTypeInUse. This basically forces the deletion of content type.

VS 2013 implements Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeatures with a call to Microsoft.VisualStudio.SharePoint.Commands.DeploymentManager.DeactivateFeature method which makes a call to SPFeatureCollection.Remove with force argument set to false which causes a call to stored procedure proc_DeactivateContentTypeInScope with SQL parameter @IsDeactivatingFeature set to 1. This prevents content type from being deleted.

I am using version of VS 2013 which is Visual Studio Premium 2013 Version 12.0.30723.00 Update 3.

I hope MS provides a fix to this issue soon. Until then I am reverting to VS 2012.

No comments:

Post a Comment