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:

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.

Why does deploying through VS work but not through Powershell?

UPDATE The command I'm executing is as follows:

Add-SPSolution C:\MySolution.wsp
Install-SPSolution –Identity MySolution..wsp –WebApplication http://sp2013srv/ –GACDeployment -Force
  • could you please share complete command of install? – Waqas Sarwar MVP Jan 13 '14 at 23:21
  • @WaqasSarwarMCSE Added – emzero Jan 13 '14 at 23:59
  • Try removing -WebApplication and see what happens. If you have elements in your WSP which are not WebApplication specific then you will get that error. – user2536 Jan 14 '14 at 9:19

The workaround is as follows:

  • Open up your SharePoint 2012 solution in Visual Studio 2012/2013
  • In the Solution Explorer (use View -> Solution Explorer if you don't see it) expand your solution and browse to the Package within your project
  • Double click on the Package.package entry to open up the package editor enter image description here
  • Click on the Advanced Tab

enter image description here

  • The Additional Assemblies screen will show with at the right a button Add. Click on it and in the menu that appears, click on Add Assembly from Project Output. enter image description here
  • At Source Project select the project in your current solution which you want to change to being deployed to a specific webapplication. enter image description here
  • You'll notice that the Location field will be automatically filled in. Leave the Deployment Target at GlobalAssemblyCache.

  • From the Location field, select the whole entry without the .dll at the end and copy it to your Windows clipboard using ctrl+c.

  • Under Safe Controls click on the Click here to add a new item button.
  • Double click on the white field in the Namespace column to edit it and paste the contents of your clipboard using ctrl+v

  • Do the same in the Assembly Name column. Your screen should now look comparable to the following screenshot:

enter image description here

  • Click OK to close the Window
  • You should notice the entry being added: enter image description here
  • In the solution explorer, click once on your project and press F4 to open its properties.
  • You will see a property called Include Assembly In Package. Switch this to False. enter image description here
  • Now Save the project and make the WSP.
  • Got to the SharePoint PowerShell and Execute the following code.

    Add-SPSolution "C:\My Projects\SharePointProject2\SharePointProject2\bin\Debug\SharePointProject2.wsp"
    Install-SPSolution –Identity SharePointProject2.wsp –WebApplication http://win-og78bueinb9 –GACDeployment
  • The output will be as follows: enter image description here

Leave your solution as it is and just add an 'Empty Element'-Item. Click on that item in the solution explorer and than double-click on the three-dots-button for the "Safe Control Entries"-Collection. There add a safe control entry. You can leave the values at proposed by visual studio. Now add that Empty Element-Item to your solution just by moving it to "Items in the Package" in the Design-View of the Packaging Explorer.

Now your solution deploys to the selected WebApplication without manipulating the default solution settings. (You'll have other problems later, if you do, for e.g. when adding WebParts with different namespaces...)

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="http://schemas.microsoft.com/sharepoint/">
  <Assemblies>
    <Assembly Location="Your Assembly File Name.dll" DeploymentTarget="GlobalAssemblyCache" >
      <SafeControls>
        <SafeControl Assembly="$SharePoint.Project.AssemblyFullName$" Namespace="Your Namespace" TypeName="*" />
      </SafeControls>
    </Assembly>
  </Assemblies>
</Solution>

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

You can refer to the following link for more information: Deploying solutions to a specific Web Application

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.