1

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 !!

2

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
  • so in this way i do not have to create .cab file is this correct? i will be working with the .wsp directly? – john Gu Dec 2 '16 at 17:02
  • yes, you don't create a cab file. With this solution you don't modify the WSP source, you will generate a copy ;) – Nico Dec 2 '16 at 17:10
  • now i did the steps , where inside the visual studio i modify the .xml file i want . then rebuild>>publish. then i upload the new .wsp file inside the solutions.. but the Activate button for the wsp will be disabled .. not sure why this is happening – john Gu Dec 2 '16 at 17:27
  • Yes you just deployed a new solution, by default all feature (Activate button) of your solution are disable. You, need to manually enable (Active) this feature with SharePoint UI or PowerShell ..... – Nico Dec 5 '16 at 8:29
1

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
  • thanks for the reply,, but seems this is a lot of work,, is there any tool that can help me in doing so ?tnx – john Gu Dec 2 '16 at 17:06
  • I'm not aware about such tool (GUI). In the past I used only command-line tools like Makecab or PowerShell. You can setup the script once and then reuse for other templates. Actually not so many work. – Sergei Sergeev Dec 2 '16 at 17:10
  • I see that ACDZip allows compression. DId you try to make .wsp again with ACDZip? – Sergei Sergeev Dec 2 '16 at 17:13
  • now as mentioned on the other reply.. i download the .wsp from the sharepoint solutions, then using VS2012 i created a new project and i was able to access the .wsp file directly inside the Vs. where i did my modifications, build>>publish the solution.. then i upload the new .wsp file inside sharepoint ,,but the problem is that the activate button was disabled,, so i am unable to activate the wsp to be able to use the site template – john Gu Dec 2 '16 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.