Using VisualStudio 2010 to create a SharePoint2010 solution, I want to deploy my solution to selected WebApplications (not to all). I can do this, by switching Assembly Deployment Target (Project Property) to WebApplication. But then, the assembly will not be deployed to the GAC.
Is there a setting which allows deployment to specific WebApplications, but deploys the Assembly to the GAC?
EDIT: Maybe the question is hard to understand, so here an example:
On a SharePoint Farm every customer hat one WebApplication. A custom feature, ordered by a specific customer, should only be usable on the WebApp of the customer. The feature should not appear in the SiteCollection features or WebSite features of other WebApps.
But the feature scope has to be Site or Web to be activated only in parts of the customers Portal.
I am not quite sure what your end goals are but you may want to keep following in mind:
When you set Assembly Target to Web Application, the compiled assembly (.dl) will be deployed to the Bin folder of the web application instead of GAC
The web application to which VS.Net deploys the SOLUTION (.wsp) is determined by “Site Url” property of the project.
Unless you are creating Sandboxed solution, the features that you deploy on server are available to all web applications irrespective of web application that you deployed the WSP to. Sometimes, You may still want to deploy the WSP to specific web application because the WSP may do following depending on the content of your WSP. For example, it may deploy assemblies to the bin folder of web application, it may copy .resx files to the folders of your web application, it may modify web.config to insert entries required by the functionality of your features etc.
If you want to deploy the WSP to more than one web application, there are several options, to name a few: using post build command of VS.Net, using central administration, using STAADM or using Powershell.
If you are using SharePoint 2010, you have a choice to deploy a solution strictly to single site collection which does not affect other site collections in the same web application or in other site collections in other web applications. These are called "Sandboxed Solutions". They are perfect fit for hosting scenariors where you have multiple customers sharing the the same farm. Definately, one of the biggest enhancement of SharePoint 2010. Again, they belong to Site Collections not to a Web application (which can have more than one site collections). there are some limitations though (for good reason) when it comes to Sandboxed Solutions. More information? See links below:
http://msdn.microsoft.com/en-us/magazine/ee335711.aspx
http://technet.microsoft.com/en-us/library/ee721992.aspx (includes the limitations)
http://msdn.microsoft.com/en-us/sharepoint/ee513156.aspx (Video Training)
Ok, now I got it: SharePoint will ask for a WebApplication to deploy to as soon as the WSP contains a SafeControl element. So if you add a dummy web part to the VS project or directly add a SafeControl element to the package in VS, the WSP will not be automatically globally deployed.
Just a thought - Why don't you control the feature activation on a web application instead of deployment.
I believe this does what you are looking for:
http://knowledge.zomers.eu/SharePoint/Pages/How-to-prevent-SharePoint-2010-solutions-from-globally-deploying.aspx