views:

436

answers:

2

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?

+1  A: 

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
+3  A: 

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