Question

I want to do some modifications to a site template, mainly to set its master page , same as mentioned here link

so i did the following stpes:-

  1. i save a site as template.
  2. i went to "Site Settings">>"Solutions".
  3. i download the .wsp file representing the site template.
  4. i rename the .wsp to .cab
  5. using a tool named ACDZip i open the .cab , edit the .xml file.
  6. save the file inside the .cab

now i am not sure how i can convert the .cab to .wsp file again? so i can upload my .wsp site template again inside the solutions ?? i tried rename the .cab to .wsp but seems this steps will modify the name not the extension !!

Was it helpful?

Solution

You can (also) use Visual Studio to Import and modify your WSP.

Have a look at this link from Microsoft (For 2010 but still working for 2013): Importing the .wsp File

in few step :

  1. Create a VS project from type : Import SharePoint Solution Package
  2. Choose your WSP (after it will create the SharePoint project with all files/elements of you wsp
  3. make your change is the solution
  4. Package and Deploy your new solution

OTHER TIPS

You can do that from PowerShell. For that purpose you need small but extremely helpful library called 'CabLib'. It's included as part of the wspbuilder (old tool to build and pack projects for SharePoint 2007).
You need to download CabLib.dll from here - WSPBuilder Extensions 1.0.6. Under the downloads select "CabLib.dll for x64 systems (version: 10.5)"

Now follow this steps:

  1. Create a folder, say testing, in that folder put CabLib.dll and your .wsp file.
  2. Create new PowerShell script in that folder, called say pack.ps1.
  3. Put following inside your pack.ps1:
$currentDir = Split-Path -Path $MyInvocation.MyCommand.Path -Parent

# LOAD CABLIB LIBRARY TO EXTRACT/COMPRESS .WSP FILES
[void][reflection.assembly]::LoadFile("$currentDir\CabLib.dll")

function Extract-Directory ( $cabFileFullPathAndFilename, $dir){
    $c = new-object CabLib.Extract
    $c.ExtractFile($cabFileFullPathAndFilename, $dir)
}

function Compress-Directory ($dir, $cabFileFullPathAndFilename){
    write $dir
    $c = new-object CabLib.Compress 
    $c.CompressFolder($dir, $cabFileFullPathAndFilename, $null, $null, $null, 0) 
}

function DoWork($action) {

    $file = "<your wsp template name>.wsp"
    $file = Get-ChildItem $file
    $fileDir = $file.Directory
    $fileName = $file.Name
    $tempFolder = "$currentdir\extracted"
    $newFile = "$fileDir\Updated-$fileName"

    if($action -eq "extract") {
        Write-Host "Extracting...."
        Extract-Directory $file $tempFolder 
        return;
    }

    if($action -eq "compress") {
        Write-Host "Compressing...."
        if((Test-Path $newFile) -ne $True) { New-Item $newFile -type file | Out-Null }

        Compress-Directory $tempFolder $newFile

        Write-Host "Cleaning Up...."
        Remove-Item $tempFolder -recurse
        return;
    }
}

DoWork($args[0])  
  1. Inside script update $file variable to point to your actual .wsp.
  2. Open Powershell in your newly created folder testing.
  3. Run .\pack.ps1 "extract". New folder testing\extracted will be created with content of your .wsp.
  4. Inside this folder perform required updates to xml files, etc.
  5. From Powershell run .\pack.ps1 "compress". Folder will deleted and new file Update-<your template>.wsp will be created with content from "extracted" folder
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top