Thursday, September 4, 2014

How to deploy a WSP to a specific Web Application

How to deploy a WSP to a specific Web Application

Many time there will be requirement to deploy a custom solution to a specific Web Application. But at the time of deployment Power Shell starts throwing the following error:

Install-SPSolution : This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application. 
At D:\XXX\YYY\DeployWSP.ps1:2 char:19 + Install-SPSolution <<<<  -Identity CustomSPSolution.wsp -webApplication "http://testSPSite" -GACDeployment + CategoryInfo : InvalidData: (Microsoft.Share...InstallSolution: SPCmdletInstallSolution) [Install-SPSolution], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletInstallSolution

From the error message it is clear that SharePoint is looking for some resources specific to the web Application and could not find any. In many cases it is possible that your custom solution don't need any web application specific resources and in those cases we need to fool SharePoint thinking that the WSP has some Web Application specific resources. To do that open you Visual Studio solution and then double click on the Package folder present in the Solution Explorer. Once it is opened, select the Manifest tab and expand the 'Edit Option' present at the bottom of the page. In general Manifest Template going to have following text:

Inside the Solution node paste the following code stub:
Change highlighted sections as described and you will be good to deploy your WSP to a specific web application from the Power Shell command prompt.

No comments:

Post a Comment