2

I have a visual studio SharePoint site that contains a list definition and content type. I need this feature to be activated on a specific site in the site collection. I set the feature scope to "web".

How to tell visual studio to which site to deploy it to (example: /Site/SubSite3) when doing a right click deploy in a Visual studio SharePoint project?

3 Answers 3

1

The simple answer is that a sharepoint solution can be deployed, whereas features contained within the solution must be activated. Visual Studio can be set to deploy the solution, but you must go into the site to activate the feature (or use stsadm/powershell in a post build script to do it for you).

When you deploy a solution, you can choose which web application(s) the solution will be deployed to. Once it is deployed, the features within it (so long as they are not hidden features) that are scoped to 'web' will show up in every web (i.e., Site) within that web application, but they will not be activated. You can then go to the site features and activate the feature you are interested in using.

If you want to prevent site administrators from using this feature except in certain sites, you can put some logic in the event receiver for your feature that will check to see if it's in the right site or not, and stop the activation if the site isn't the right one.

If you want to automatically activate this feature on a specific site and not allow site admins to see this feature (i.e., not be able to activate / deactivate it), you could mark your site feature as hidden and, in addition, create a farm scoped feature (farm scoped features are automatically activated) that has an event receiver that finds the appropriate site and activates the hidden site feature for you. However, you have to be careful of using this method, because you have to hardcode your site's relative URL into your solution, which makes your solution inflexible.

1

I guess your talking about SharePoint 2010 right? Basicly, from my experience, the feature will be added to each site. Tho you can put the "Activate by default" on fase... Then you go to the site you want and activate the site level feature.

I think, tho i might be incorrect, that a web feature will be deployed to your webapplication. And then will be availble on ALL sites. This means it can be activated on everysite. But if you disable the activate on default it will not be activated after deployment.

But it is possible that deploying with VS2010 will activate the features anyway (doesnt matter if u disable the option or not). But when you deploy the wsp file without visual studio it will work for sure.

If you do not understand, feel free to ask!

1
  • You can also try changing the deployment url to: servername:port/sitecoll/site but my guess is that it will still be deployed to your webapplication and available to all the sites. Commented Nov 23, 2010 at 14:54
1

If your SOLUTION just contains List definition and Content Type, you should consider creating a Sandboxed Solution.

Your project's properties contains following properties which you are interested in:

  1. Sandboxed Solution (Yes/No)
  2. Site Url - the URL to which the solution will be deployed when you click "Deploy" option.

More information in Sandboxed solution: http://technet.microsoft.com/en-us/library/ee721992.aspx

NOTE: The artifacts contained in Sandboxed solution belong to only the site collection to which the Sanboxed solution is deployed and not available to other site collections unless you exclusively deploy to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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