Add & Install SPSolution to a Specific WebApplication Instead of Globally

I have a SP2013 solution that contains a custom WCF service, custom Timer Job and a Feature Event Reciever. Because of these the solution Assembly Deploying Target is set to GlobalAssemblyCache. The Feature is scoped to Web Application because I want to install it only for a unique WebApplication in the farm.

When I deploy it using Visual Studio 2012, no problem. But when I try to use powershell I get:

Add-SPSolution C:\MySolution.wsp
Install-SPSolution –Identity MySolution.wsp –WebApplication http://sp2013srv/ –GACDeployment -Force

Install-SPSolution : This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application.
I can't change the deploying target to Web Application because that will break the Custom Timer job and feature event receiver.



You can try to add a dummy safe control entry to your package file as SharePoint checks whether there are items which have to be deployed to specific web application when adding your solution to solution gallery, and one of them is safe control entries.

To add a dummy safe control in Visual Studio:

  1. Open the solution's Package
  2. Select Manifest tab
  3. Expand 'Edit Options' area
  4. Add some dummy safe control XML. The Edit Options text area will end up looking something like the following:
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="">
    <Assembly Location="Your Assembly File Name.dll" DeploymentTarget="GlobalAssemblyCache" >
        <SafeControl Assembly="$SharePoint.Project.AssemblyFullName$" Namespace="Your Namespace" TypeName="*" />

Note: You'll need to change Your Assembly File Name and Your Namespace in the above XML.


No Comments

Add a Comment