Usually, when you develop a SharePoint solution in Visual Studio, you have access to all the solution files including the generated WSP file. So, you would generally not need to download WSP files directly from SharePoint central admin.
In an ideal world that is…
But sadly (or perhaps fortunately), we don’t live in an ideal world! There have been many situations in my SharePoint development career where I have needed to grab a WSP solution file directly from central admin.
I’ll give you one example scenario and then share the PowerShell code used to do the download.
Scenario: When You May Need To Download A WSP File From Central Admin
Let’s say you just inherited a poorly documented solution that is currently deployed and running on your company’s SharePoint farm. This solution was last maintained maybe years ago.
Thankfully, you also have access to a folder dedicated to this solution that contains all the Visual Studio solution/project files including WSP files inside the bin\Debug (or bin\Release) folders.
Problem is… there is more than one solution (codebase) in the dedicated folder and more than one WSP file!
And since versioning may not have been very well done, you cannot be too sure which of the WSP files you have is currently deployed and activated on your company’s farm.
You have been tasked with updating the code to add new features. But if you mistakenly update and deploy an old version, certain features that currently work well may break.
To save your ass if something goes wrong, you may want to keep a copy of the currently deployed WSP file that sits in SharePoint central admin.
I think this is a good idea even if you’re working on a relatively low risk development server.
That way, if any of the old features break after you push your update, you can just revert to the “last known good” version while you go back to the drawing board and try to figure out which codebase was previously deployed.
PowerShell Code To Download WSP Files
$farm = Get-SpFarm $file = $farm.Solutions.Item("your_solution_filename.wsp").SolutionFile $file.SaveAs("C:\FolderToSaveDeployedWSPFiles\your_solution_filename.wsp")
Make sure the folder C:\FolderToSaveDeployedWSPFiles exists. Replace your_solution_filename.wsp with the correct filename, and then run the above script.
You can either save and run the script as a .ps1 file or run it line by line.
Your deployed WSP file will be downloaded and saved in the specified location.