Save WSP file from SharePoint Farm
It’s very important for SharePoint administrator to have all actual WSP-files of custom SharePoint solutions. Developers often make new builds and administrator installs it in test environment, then in productive one. All the WSP-files are usually stored in a special place.
But in real life often everything is not so good. Old WSP-files are often lost and you can’t find them. But SharePoint farm works and everything is ok and you don’t remember about WSP. But once a new version of WSP file is sent and you are going to install it. And you want to have a previous version to undo update. But you don’t have a previous WSP. What to do?
Using powershell it’s quite easy to save WSP-file of solution from a SharePoint farm. Insert code to you .ps1 file, change solution file name and execute it.
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{ Add-PSSnapin Microsoft.SharePoint.PowerShell }
$farm = Get-SPFarm
$solutionName = "sharepoint.mycutomsolution.wsp"
$file = $farm.Solutions.Item($solutionName).SolutionFile
$file.SaveAs("D:\Install\_backup\$solutionName ")