2
votes

I am developing a solution for SharePoint 2010 SP1. My solution provides several timer jobs, which are instantiated using a feature and a feature receiver.

The feature is scoped to a WebApplication, which seemed natural since the timer jobs are associated with the same web application. The solution is also a full-trust solution.

The solution deploys to a specific web application (http://portal.xyz.net), and only to that web application; however, it appears that the feature gets activated on all web applications within the farm, except Central Administration. As a result, the timer job gets created on all web applications.

This causes failures in some cases, and redundant code execution in others. What I really want is for the feature to activate only on the web application to which I deploy the solution.

Any ideas on how I can configure this properly?

Update 1

We have tried deploying the solution three ways, all with the same behavior:

  • Using Visual Studio
  • Using the Central Administration web application
  • Using the following PowerShell command:

    Add-SPSolution -LiteralPath C:\Nu.SharePoint.Portal.wsp Install-SPSolution -Identity Nu.SharePoint.Portal.wsp -GACDeployment -WebApplication http://portal

After the deploy step in any case, we see the solution deployed to the single web application, but the WebApplication-scoped features are activated on all web applications except central admin. The behavior we want is to activate these features only on the application that we deploy to.

3

3 Answers

2
votes

If you want to prevent the timer job from activating on all of the web applications you just need to set the Feature property called "Activate On Default" to False. When you deploy the feature to a web application the feature will not activate so you just need to activate it through Central Admin or a PowerShell script. You can modify the Feature property in Visual Studio by opening the Feature Designer, selecting the feature on the left and it's the first property in the Property window.

1
votes
  1. Go to the Feature and Give F4
  2. In the Properties window, Select False in Activate on Default Property.
  3. Then deploy the solution.
0
votes

did you use PowerShell to deploy you WSP or are you deploying from within Visual Studio. By using the PowerShell commandlets for SharePoint you could easily configure where the features will be deployed to.

Add-PSSnapIn Microsoft.SharePoint.Powershell
Add-SPSolution -LiteralPath C:\install\MyWSP.wsp
Deploy-SPSolution -Identity MyWSP.wsp -GACDeployment -WebApplication http://mysite

While Deploying WSPs manually from CA you're also able to select the WebApplication your features will be deployed to.

By default your features are deployed to all WebApps in your Farm