This topic is about how to edit the contents/files of WSP file and rebuild it.
In a recent time, I come to a situation where I need to extract the WSP file to edit the files like ONET.xml, feature.xml, etc. Exacting contents of WSP and modifying them is fine but rebuilding the WSP is not straight forward and its not possible by just renaming it.
After spending some time, I ended up with the following approach to rebuild the WSP successfully.
Step 1 : Rename WSP file to CAB and extract all the files
1. Rename the WSP file to CAB
2. Extract the CAB file using 7 Zip or any other tool
Step 2: Modify the necessary files.
Step 3: Use DDFGenerator from CodePlex
Now, we need to generate a DDF file using a CodePlex component
DDFGenerator based on our WSP contents. It is an executable file.
1. Download the DDFGenerator and place the file in any of the physical drive folder
2. Open the DDFGenerator folder path directory in Command prompt
3. Enter the following command with the path to our WSP file contents folder
C:\[DDFGeneratorFileFolder]>
DDFGenerator "C:/path/WSPSolutionFolder"
4. The above command will create a DDF file with the name "solution.ddf"
5. DDF Generator doesn't put an entry in DDF for WSP file name. So it is required to edit the ddf file to put the following entry similar to other entries in the DDF file (mostly as a second entry) create WSP file
.Set CabinetNameTemplate=<SolutionName>.WSP
6. Check if file paths in DDF are having spaces in between. If yes, enclose file path using double quotes. This is required to avoid errors while executing the next step.
Ex: .Set DestinationDir = "1TeamSiteListInstances\Files\Lists\Team Discussion\"
"1TeamSiteListInstances\Files\Lists\Team Discussion\Schema.xml"
Step 4: Run MakeCab.exe to create CAB and WSP files
Now we need to run MakeCab command as below to generate WSP file.
C:\[DDFFileFolder]> "MakeCab.exe /F <solution.ddf> "
After executing the above command, the WSP file will be created. (A folder with a random number as name will be created and WSP file will be placed in that folder).
Thats it !!!