I'm trying to figure out how to extract a solution file .wsp file from a SharePoint server. Is this possible and if so how?
Asked
Active
Viewed 1,492 times
2 Answers
5
You can make a small console application and access the solutions using the SPFarm.Local.Solutions property. Include the Microsoft.SharePoint.Administration namespace and use the following code snippet to download the solution file:
SPSolutionCollection solutions = SPFarm.Local.Solutions;
foreach (SPSolution solution in solutions)
{
SPPersistedFile wspFile = solution.SolutionFile;
wspFile.SaveAs("c:\\Temp\\Solutions\\" + solution.Name);
}
You need to make sure that your output directory exists before calling the SaveAs() method. If it does not exists an exception is thrown.

Thomas Favrbo
- 695
- 4
- 10