3

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?

James
  • 12,636
  • 12
  • 67
  • 104

2 Answers2

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
1

You can access the Solutions on a farm by using the SPFarm.Local.Solutions property. I'm not sure if you can retrieve the underlying file though. That's where I'd start.

Jason
  • 15,915
  • 3
  • 48
  • 72