5

I want to deploy my solution to a single web application. I used the following script:

Add-SPSolution -c:/mywebpart.wsp

Install-SPSolution mywebpart.wsp -WebApplication "SharePoint Debugging" -GacDeployment

But the solution is now available in the 'Site Collection Features' list of all web applications.

I know I can deactivate the feature on the web applications where I don't use it, but I don't want it to be deployed to those web applications. How can I deploy the solution so my web part is only available in a certain web application. The idea is that I want to be using the same web parts in the different web applications, but they have minor changes for each different web application. So I want to deploy version 1.1 to web application A and deploy version 1.2 to web application B

  • can you try below lines Install-SPSolution –Identity $wsp -GACDeployment -force -WebApplication "test.com" – Amit Nov 25 '13 at 9:43
8
Install-SPSolution -Identity <solution.wsp> -WebApplication <name or guid of web app> -GacDeployment

the above should work! what is your solution scoped to? farm webapp site web? It should be scoped to site to be deployed to a specific webapp! under central admin look at the wsp list and see where its currently deployed to, is it global or to specific webapps?

or cheating you could do, as your setting it as webapp you need to ammend the manifest file that is auto generated.

under package.package look at the ui (user interface) at the botton expand more options to edit the xml result, now add in some safe control for the feature:

<SafeControls>
  <SafeControl Assembly="[Assembly Name]" Namespace="[Namespace]" TypeName="*" Safe="True" />
</SafeControls>

now save and redeploy using powershell and you should see that it only deploys to a single webapp ;)

EDIT

ok i now understand what your trying todo! unfortunatly its not possible still in 2010 or 2007 dont know about 2013! youll need to redevelop your solution to be sandboxed or to make the feature invisible and only activated or deactivated through code!

the reason your seeing the solution (feature) in all site collections under all webapplications is becuase its within the drive feature folder within the hive files and no way to state which is visible to what webapp

  • The post states that the user finds the feature in Site Collection features, so scope should be OK? – Robert Lindgren Nov 25 '13 at 10:53
  • what i mean is, you have the solution wsp and you have the feature, you could have the solution deployed to a specific webapp but the feature could be at farm level ;) so to understand what is going on i wanted him to clarifiy exactly where the solution is and where the feature is set to go to. obviously i had a feeling it would be at sitecoll level as he stated but he only wants it in one not all – Ali Jafer Nov 25 '13 at 11:10
  • I removed the solution from the farm. then went to visual studio and changed the scope in the Feature1.feature file to 'site' I then clicked the deploy button and again the feature was available in all web applications. I just need it to be available to the one web application and ignore other web applications. What to change? – Pieter Du Toit Nov 25 '13 at 11:29
  • can you see the package.package (in VS)? you need to click on that, when it opens up (in VS) you should see some xml and also at the bottom text (+ more options), click on that to edit the generated xml, now add the code that iv put up for safecontrols filling it will with the project details and save, build and then deploy... it should only deploy to a give webapp that you set and nothing else! – Ali Jafer Nov 25 '13 at 11:47
  • @PieterDuToit just ammended my answer! – Ali Jafer Nov 25 '13 at 11:50
6

Following are the powershell commands to deploy a wsp to single web application:

Add-SPSolution <wsp file name>.wsp

Install-SPSolution –Identity <wsp file name>.wsp –WebApplication <Site URL>  –GACDeployment
  • Although this method works and the solution is deployed and activated on the specified web application, the feature is also available in the site collection list on all other web applications but not active. – Pieter Du Toit Nov 25 '13 at 12:44
  • Activate the feature using following PS command: Enable-SPFeature -Url "[Site Collection URL]" -Identity <FeatureName> – Chaithanya Nov 26 '13 at 7:00
0

I just appending Ali answer that it will be better to create Assembly information Assembly="[Assembly Name]" during run time with hard coding the value. Otherwise sometimes, it throws error.

You can find the solution over http://asharepointsolutions.blogspot.in/2014/09/how-to-deploy-wsp-to-single-web.html

Hope it will clear out more to you.

  • <SafeControls> <SafeControl Assembly="[Assembly Name]" Namespace="[Namespace]" TypeName="*" Safe="True" /> </SafeControls> i tried this in my package xml file, but it throws some error and it didnt work. can you pls xplain in a elaborated way? – SaMolPP May 9 '17 at 6:13
  • this wont work for SP 2013. This will give you error : Error 1 Error occurred in deployment step 'Add Solution': Error: Cannot find this file specified in the manifest file: SharePointProject1.dll – SaMolPP Jun 15 '17 at 0:15
-1

Try specifying the site collection URL where you want to install the Solution

Install-SPSolution –WebApplication "[Site Collection URL]" -GACDeployment

If you have two different Web Applications instead of Site collections, you may change the name of your solution (Ver1 and Ver2) and grant permissions only to Admin for viewing "Site Collection Features" option.

  • Tried it - still deployed the solution to all web applications - when I say 'deployed' I mean the item is available in the site settings - site collection features, although not active. – Pieter Du Toit Nov 25 '13 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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