Thursday, 7 June 2012

An annoying error might happen when deploying SharePoint 2010 solutions. The feature will refuse to install itself, and the following error message will be shown post-deployment:

Error occurred in deployment step 'Add Solution': A feature with 
ID 00000000-0000-0000-0000-000000000000 has already been installed 
in this farm.  Use the force attribute to 
explicitly re-install the feature.
 
This error happens if you deploy a solution which contains a visual web part to a different web application on the same farm as the web application where it is already installed. In other words, you have two web applications, A and B on the same SharePoint farm. You want to deploy solution S which contains a visual web part to web application B, but it is already deployed to web application A. If you deploy the solution S to web application B, you will receive this error. The MSDN article Troubleshooting SharePoint Packaging and Deployment mentions this problem is caused by a visual web part. This is imprecise. It is caused by the user control (a visual web part contains a user control). You may face this error in any package which contains a user control. The article also menthions a possible fix to the problem by simply running the deployment process again. However, in certain situations (and in all situations I have faced this problem), this fix will not work.
The fix to this problem is actually mentioned in the error message, though it is well hidden. You can do this fix in both Visual Studio 2010 or PowerShell. I will leave STSADM.EXE out of this as it is deprecated, and should be used as little as possible. The fix in Visual Studio 2010 is to double-click on the feature in question and open the feature window. From there, use the properties window and set the value of Always Force Install to true.
If you are hardcore and still prefer notepad (like certain people still do), you can edit the Feature elements of your solution. To force installation of a feature through editing code, open the Feature.xml file add the AlwaysForceInstall attribute with the value TRUE to the Feature element:

<Feature AlwaysForceInstall="TRUE">
...
</Feature>
 
In PowerShell, you can use the -Force parameter of the Install-SPSolution commandlet in order to force the installation of a solution:
Install-SPSolution -Identity <solution_file> -GACDeployment -Force
If you follow any of the advice described above, you should have no trouble next time you face this error after a SharePoint 2010 deployment gone wrong.

No comments:

Post a Comment