Limiting feature to 1 web application [duplicate]
-
11-10-2020 - |
문제
I have an Empty SharePoint 2013 project with a single feature (also empty, I am testing) scoped at WEB. When I deploy the solution it is deployed to all Web Applications and visible in every existing subsite.
GOAL: I want to see the feature only in Site Features of the specified WebApplication (WebApp5). I do not want to see it (Activated or not) in sites under any other WebApp (WebApp1, WebApp2, etc.)
What I tried so far:
- deploy via VS (Build>>Deploy Solution)
- publish and deploy via Powershell:
Add-SPSolution -LiteralPath C:\published\crap1\1.2\testDeployment2.wsp Install-SPSolution -Identity testDeployment2.wsp -WebApplication http://win-0pjj59787on:28840/
- publish and deploy via Powershell:
Add-SPSolution -LiteralPath C:\published\crap1\1.2\testDeployment2.wsp Install-SPSolution -Identity testDeployment2.wsp -WebApplication http://win-0pjj59787on:28840/ -GacDeployment
The solution shows as deployed to the one WebApplication, but the feature is still available and can be activated from any other WebApplication:
Please tell me there is something better than hiding the feature.
해결책
This is happening because the feature files get deployed into the File System and it gets picked up by all web applications.
There is no straight forward solution to this problem. The one workaround you can use is by creating a dependency with a web application feature
- Create an empty feature an scope it to web application
- Now open the web scoped feature and add a dependency to the above feature
Now if anyone tries to activate it in another site collection it will not get activated unless you activate the web application feature.
http://nikcharlebois.com/scoping-a-sharepoint-feature-for-a-specific-web-application/