Friday 12 July 2013

How To Extract SharePoint WSP Solution and Repack to WSP

If provided a third party SharePoint WSP solution, there may be need to edit contents of the package to conform with governance for the SharePoint farm.

To extract the contents of a WSP package, make modifications, and repackage the WSP:
1. Download and install WSP Builder or WSP Builder Extensions (http://wspbuilder.codeplex.com/) from Codeplex
2. Run the command prompt as an administrator
3. Change the current directory to the directory including WSPBuilder.exe (e.g. "cd C:\Program Files (x86)\WSPTools\WSPBuilderExtensions")
4. Run the following command from the command prompt, replace {WSPLOCATION} with the location of the WSP and the {OUTPUTLOCATION} with the folder to extract the contents
    WSPBuilder.exe -o extractwsp -filename {WSPLOCATION} -targetpath {OUTPUTLOCATION}
Eg: WSPBuilder.exe -o extractwsp -filename C:\Users\JohnJay\Desktop\Temp\Template.wsp -targetpath C:\Users\JohnJay\Desktop\Temp
5. Make any modifications neccassary to the extracted files, I had to Remove the unwanted Site Features from ONet.xml file.
6. Run the following command from the command prompt, replace {WSPLOCATION} with the location of where the WSP should be created and the {OUTPUTLOCATION} where the previously extracted contents exist
   WSPBuilder.exe -ProjectPath {OUTPUTLOCATION} -SolutionPath {OUTPUTLOCATION}  -Outputpath {WSPLOCATION}
Eg: WSPBuilder.exe -ProjectPath C:\Users\JohnJay\Desktop\Temp -SolutionPath C:\Users\JohnJay\Desktop\Temp  -Outputpath C:\Users\JohnJay\Desktop\Temp
Once the WSP is packages, it should behave as a typical SharePoint solution deployable via the STSADM command line or through PowerShell.