SP2010 WSP Global or not?

Forcing a WSP to be deployed as local to a webapp

In some cases a WSP is deployed to all WebApps (= Global). In other cases you can select which WebApps you will deploy the WSP to.

But what makes the difference?

When you in CentralAdmin goto System Settings – Manage Farm Solutions – Select a Wsp

If Contains Web Application Resource: Yes then it can be deployed to individual WebApps.

So how can you control this setting?

If you in Visual Studio goto Package.package – Manifest see some line with <SafeControls> like

<SafeControls>
<SafeControl Assembly="MyApp.Navigation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=de0229056b231800" Namespace="MyApp.Navigation" TypeName="*" />
</SafeControls>

then the package will have a WebApp resource.

You can add SafeControls via Package.package – Advanced. If you have added a dll to be included in your package using the designer as in step 1:

… then you can edit the dll by selecting it and press Edit. In the new window click on the long button under “Safe Controls” in order to mark some or all of the dll as safe (step 3).

This will add lines to your manifest:

<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="d82b5473-4d1a-4ce1-ab4e-d5ce2acd9af3" SharePointProductVersion="14.0">
<Assemblies>
<Assembly Location="Portal.Collaboration.GeneralWebParts.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Namespace="Portal.Collaboration.GeneralWebParts" TypeName="*" />
</SafeControls>
</Assembly>
<Assembly Location="Portal.Collaboration.Common.dll" DeploymentTarget="GlobalAssemblyCache" />
</Assemblies>
<!-- more stuff -->
<Solution/>

But you could have saved the trouble and just written the same lines in \Package\Package.Template.xml.

Package.Template.xml has an advance that you could have written those lines for your dll from your project. Your project dll is added to the package automatically and safecontrols are also added automatically, when Visual Studio beleaves they should be included. But in this case, when Visual Studio don’t want to add them, then you can add them manually via Package.Template.xml and force the WSP to deployed to individual WebApplications.

Also do check-out a little trick to add dll’s as SafeControls: http://weblogs.asp.net/jan/archive/2010/08/06/easily-adding-safecontrols-in-sharepoint-2010-with-visual-studio-2010.aspx

Deployment dependency

While you are fiddling with \Package\Package.Template.xml then you could add some lines that forces a package with an external dll to be deployed before you can deploy your own package. You will get a friendly error message if the external package yammer.sharepoint.features.wsp is not deployed before your wsp is being deployed.

<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="<a href="http://schemas.microsoft.com/sharepoint/">http://schemas.microsoft.com/sharepoint/</a>">
<ActivationDependencies>
<ActivationDependency SolutionId="77201d26-40c5-4ccf-9305-a9a6cd1cf28f" SolutionName="yammer.sharepoint.features.wsp"/>
</ActivationDependencies>
</Solution>

SharePointWSPs

The End

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: