Tuesday, June 26, 2012

Deploy assembly to GlobalAssemblyCache or Web Application in SharePoint 2010

Introduction:
In this article we will discuss how to deploy an assembly to GlobalAssemblyCache or Web
Application Bin folder in SharePoint 2010.

Description:
Suppose we need to deploy a Visual WebPart to SharePoint 2010 which internally refering to a 3rd part dll. Then we need to add the assembly in the package before making the .wsp file.
By default the Assembly Deployment Target is set to GlobalAssemblyCache in Visual Studio
2010. So we need to change the deployment target to WebApplication. For this Select the Project and press F4. This will open the Properties widow. From there Change the Assembly Deployment Target to Web Application and Include Assembly In Package to True as shown in the figure below.
And in the next step we need to add the assembly to package. For this Double click on the
package in the solution explorer. This will open the Package.package in designer mode. Below 
there are 3 tabs in the page like Design, Advanced and Manifest.
Click on the Advanced tab. This will open additional assemblies section. From that section click on Add as shown in the figure below:


When you click on Add and click on Add Existing Assembly as shown in the figure below.

This will Open the dialog box for add existing assembly as shown in the figure below. There you can add the assembly. Here we need to select Deployment Target Web Application radio button. And then click on OK.
This will add the assembly to the bin directory of the web Application which is located in C:
\inetpub\wwwroot\wss\VirtualDirectories\[WebAplication]\_app_bin.