CoolWriteups Solved: SharePoint 2010 Migration – How To Deploy A Single Web Part DLL File To The Global Assembly Cache (GAC)

When migrating from a MOSS 2007 environment to SharePoint 2010 you will have a heap of Web Part DLL files to deploy from MOSS 2007 servers to the SharePoint 2010 GAC. You may only have access to the Class Library project created in Visual Studio 2005, as I did. I noticed when I opened the project in Visual Studio 2010, it did not give me the option to use it’s Packaging feature.

So, for anyone out there interested in deploying a DLL to SharePoint 2010, this is how I did it. If anyone reading this thinks I’ve made a mistake then please let me know.

So let’s say I want to deploy a web part DLL only called ‘HelloWorld.Dll’. The best way to do it is to wrap it in a WSP and deploy it using Powershell.

1. Open the Class Library project in Visual Studio 2010 and let it convert it, make sure you take a backup always;

2. To the project I added a folder and called it ‘Package’, you can call it whatever you like;

3. To the Package folder add an XML file and call it ‘Manifest.xml’ along with a text file but call it ‘HelloWorld.ddf’. Make sure it does not have a .txt extension;

4. Open the Manifest.xml and add a SolutionID and the name of the Dll:

Manifest.XML Example

5. To the .DDF file add the following:

;*** Sample Source Code MakeCAB Directive file example
;
.OPTION EXPLICIT ; Generate errors
.Set CabinetNameTemplate=HelloWorld.wsp
.set DiskDirectory1=”..\bin” ; All cabinets go in a single directory
.Set CompressionType=MSZIP;** All files are compressed in cabinet files
.Set UniqueFiles=”OFF”
.Set Cabinet=on
manifest.xml
HelloWorld.dll
;***

6. Build the Solution, this will generate a DLL file to the ‘obj/Debug’ folder;

7. Copy the DLL file from the obj/Debug folder and paste it in the Package folder;

8. Now copy the complete HelloWorld solution to a temporary folder in your SharePoint 2010 Application Server. My temporary folder is called ‘Projects’ in my C:\;

9. Now open a normal command prompt and navigate to C:\Projects\HelloWorld\Package folder;

10. Next, create a WSP by running the following command:

MakeCab /F HelloWorld.DDF

11. The WSP file generated can be found in the BIN folder of the project. This is the WSP file we are going to deploy to the GAC of the SharePoint 2010 server;

12. Now while you are in your SharePoint 2010 server, open Powershell and type the following command to install the WSP file:

ADD-SPSolution -LiteralPath “C:\Projects\HelloWorld\Bin\HelloWorld.wsp

13. Once the WSP is installed, open Central Admin > Server Settings > Manage Farm Solutions and click the HelloWorld.wsp link;

14. Click Deploy solution to deploy it globally. Open C:\Windows\Assembly to find the HelloWorld.DLL file in the GAC;

15. Once the DLL is deployed to the GAC, it needs to be added as a SafeControl in the Web.Config file of the Application;

16. To do this first right click on the DLL file in the GAC and make a note of the Public Key Token;

17. Then go to C:\InetPub\wwwroot\WSS\Virtual Directories\80 and first make a copy of the web.config file. Then open the original web.config file and search for ;

18. Add the following entry to the SafeControls list:

Web.Config Safe Control Entry

19. Save the web.config file and close it;

20. Refresh your page that uses the web part and all should be working fine.

If you feel I have left anything out please let me know or if you need assistance feel free to get in touch.

Cheers

Join the Forum discussion on this post

Derek Halstead is a SharePoint consultant as well as the founder and principal of CertifiedSolutionsAustralia.com and CoolWriteups.com. He has 16 years of experience in the IT industry, with over ten years focused on Microsoft SharePoint. He can be reached by using the Contact Me link in the top menu.
Back to Top