Getting solution files from SharePoint Reply

Mike BerrymanAnyone who has ever done any sort of custom development for SharePoint knows about .wsp files.  If you don’t know, .wsp files are packaged (IE zipped) collections of files that are deployed to a SharePoint farm.  This includes dlls, features, custom controls – just about anything done in a custom development situation for SharePoint gets packaged into a .wsp file for deployment purposes.  You can view the .wsp files deployed to any SharePoint farm via central administration.

Chances are also good that anyone who has ever done any sort of custom development for SharePoint also has run into situations where they need access to these .wsp files.  The most common situation would be where the frontend is switching to another server and all these custom solutions need to be re-deployed to the new server.  If you have access to the codebase that generated any of the custom solutions, that’s great; just get the .wsp from the code and you’re golden!  But what of situations where you may not have access to the code that generated the .wsp file?  What of a case where the person(s) responsible for the web frontend don’t actually have the .wsp anymore?  What’s a developer to do?

There’s no way through the Central Administration UI to download a .wsp file, but luckily enough there is a really simple way to do this through powershell using only 2 lines:

$solution = Get-SPSolution SolutionName.wsp
$solution.SolutionFile.SaveAs("C:\SolutionName.wsp")

Of course this assumes powershell is opened with the requisite SharePoint assembly loaded.  If using just basic powershell, you’ll need to load the SharePoint assembly:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

That’s it! Never again will you need to scramble and dig for a .wsp deployed to any farm.

Leave a Reply

Fill in your details below or click an icon to log in:

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