How to deploy a SharePoint WSP

Author by Mark Rentmeester

In our development world, especially with Visual Studio 2010 and SharePoint 2010, we have it very easy for deploying our solutions to SharePoint. As long as we have SharePoint installed on the same box as Visual Studio, we just right click the solution and deploy. Moving into the real world though, you'll quickly find that having Visual Studio 2010 on a production or staging environment is not always there. Somehow we have to get our project from source code, to an assembly, and then to SharePoint. You may have asked:

  • How do I deploy a SharePoint 2010 Solution or WSP file?
  • How do I create my SharePoint 2010 WSP file?
  • Where is my SharePoint 2010 WSP file?

Let's jump right in and answer those questions...

Assumptions

  • You have a Visual Studio 2010 SharePoint project set up and ready to go.
  • The project compiles.
  • Are able to use powershell.

If you're looking for a great starter project for SharePoint, why not try your hand at Creating a custom Web Part?

Generating the WSP

The first step is to build your project. So, right click on your project/solution in Visual Studio and choose "Build." Now depending on your configuration, you're either going to be building to a debug or release directory. Whatever your scenario is, browse to that location on your hard drive (either of these two directorys will be located in C:bin. Your directory should look something like this to the left. There should be, at least, an assembly dll and your .wsp file. From this point onward, you'll only need that .wsp file. For the sake of keeping things short, let's move this file to a C:deploy directory.

Adding the WSP

  1. Open the SharePoint 2010 Management Shell. You can get to this by going to Start > All Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell. Using this will automatically run PowerShell and set up the Microsoft.SharePoint.PowerShell snappin for us.
  2. Type Add-SPSolution c:deploy.wsp
  3. You should now see a table like structure showing the solution name, its ID and that your solution has not yet been deployed...

Deploying the Solution

Deploying the solution is now taken care of by one command in PowerShell now called Install-SPSolution.

  1. Back in PowerShell, type: Install-SPSolution –Identity .wsp –WebApplication http:// -GACDeployment
  2. You're done. Verify that your assembly is the GAC (C:windowsassembly) and then go activate any features you may have had in your solution.

Quick Overview

Here's a quick overview of what we've learned with a few more tidbit commands you'll probably need along the way:

  • Add Solution Add-SPSolution c:.wsp
  • Deploy/Install Solution Install-SPSolution –Identity .wsp –WebApplication http:// -GACDeployment
  • Update Solution Update-SPSolution –Identity .wsp –LiteralPath c:.wsp –GACDeployment
  • Uninstall Solution Uninstall-SPSolution –Identity .wsp –WebApplication http://
  • Remove Solution Remove-SPSolution –Identity .wsp

Need More?

Of course, I can't include every possible iteration, scenario and permutation of your deployment process or strategy. If the above commands aren't working for you, you'll find some more detailed information about the commands here:

This article was originally written by Jordan Laik. It is moderated currently by Mark Rentmeester.

Author

Mark Rentmeester

Director of Application Development Services