Recently I got a requirement to check the contents of a wsp which was already deployed on the Client's SharePoint server. I have given access to Central Admin, but as you know SharePoint will not provide us any link to download/extract the deployed wsp.
These are the ways I found on the web to download/extract the wsp..
- Using Power Shell Script
- Using Code
1. Using PowerShell script :
$myFarm = Get-SPFarm
$myWSP = $myFarm.Solutions.Item("documentspacenew.wsp").SolutionFile
$ myWSP.SaveAs("c:\purna\ documentspacenew.wsp")
This will be saved as
2. Using Code :
protected void btnGetWSP_Click(object sender, EventArgs e)
{
SPSolutionCollection allSolutions = SPFarm.Local.Solutions;
foreach (SPSolution mySolution in allSolutions)
{
SPPersistedFile myWSP = mySolution.SolutionFile;
if (myWSP.Name == "documentspacenew.wsp")
{
myWSP.SaveAs("c:\\Purna\\" + mySolution.Name);
}
}
}
{
SPSolutionCollection allSolutions = SPFarm.Local.Solutions;
foreach (SPSolution mySolution in allSolutions)
{
SPPersistedFile myWSP = mySolution.SolutionFile;
if (myWSP.Name == "documentspacenew.wsp")
{
myWSP.SaveAs("c:\\Purna\\" + mySolution.Name);
}
}
}
Here the SPSolutionCollection , SPPersistedFile classes are referred from Microsoft.SharePoint.Administration namespace.
Finally I have got the contents of the downloaded solution by changing the extension from .wsp to .cab.
Hope Helpful..!
Helpful
ReplyDeleteThank you.
ReplyDeleteSuperb Madugula ............:)
ReplyDelete