Skip to content

Editing contents of a WSP (SharePoint)

July 7, 2010

When deploying a new SharePoint feature for a trial upgrade 2010 environment, I was striking a problem with the contents of the WSP.  

Inconsequential to this story, there was a SYSTEM.WEB.DLL file within the WSP – and SharePoint 2010 would not allow it to be deployed (which is a good thing !)

clip_image002

My thinking was to just ‘remove’ the offending DLL from the WSP, and re-deploy.

WSP –> CAB File

In case you were unaware, you can see the contents of the WSP by changing the file extension to CAB.

You can then open the file like a ZIP file within Windows Explorer, or via WinRAR (my choice of zipper).

Can’t Update Contents

BUT – and this is the annoying bit – you CANNOT change the contents of the CAB file, and thus the contents of the WSP.   For a file type that is vital to the operation of SharePoint 2010, there is no way to simply modify the innards of a WSP file.

The preferred approach (?) is to open the WSP within Visual Studio 2010 – and/or Visual Studio 2008 along with WSPBuilder.   BUT – that’s not really a workable solution, when needing to do a ‘quick’ update – or modify the contents within a server environment.  

No, I’m NOT going to install Visual Studio on the server !!

The Problem

So – how do you do it ??    How do you delete a file from a WSP – and/or update the MANIFEST.XML file ?

From some fiddling, testing and trials – these don’t work :

  • Creating a new archive file within Windows Explorer – and changing to CAB or WSP extension
  • Trying to delete or drag into an archive shown in Windows Explorer
  • Creating a new archive with WinRAR – and/or dragging into a CAB file using WinRAR
  • Using MAKECAB.EXE to create an archive via command line
        • It’s just too fiddly & difficult
        • Need a DDF definition file to define the constructs – if needing to do more than ONE file (!)
        • And, the help files from Microsoft (for MAKECAB + CAB SDK) have been dropped/yanked
        • All other technical documentation in this area relates to MS-BUILD instead.
  • Try a different zipping tool (7-Zip), based on a recommendation from a work friend to create or edit CAB
  • Try yet another zipping tool (IZArc) – after another work friend said that he’d used it with success (?)

BUT – none of the above worked for me !

aaarrrrgggghhhh !!

About the only way that I could think of – and supported by suggestions from other work colleagues – was to use WSPBuilder and/or Visual Studio.

I’m staggered – and a little bit annoyed – that there is no decent tools for managing the contents WSP’s – especially given the importance (vitality !) for SharePoint 2010.  

If anyone knows of any such tools – then let me know – please !

The Solution :    Smile

I’m happy to report that there is one such zipper product (tool) that allows you to create a CAB archive – and then rename to be a WSP – and problem solved !   

It turns out I was sooo close to getting it sorted out – using IZArc – there’s a minor quirk which I’ll explain in a moment – but it definitely works !    Yay !

The steps involved to update the WSP are as follows :

  1. Rename the WSP to CAB
  2. Extract all contents to a folder – using Windows Explorer, or WinZip, WinRAR, or whatever
  3. Change the items you want, ie. MANIFEST.XML and remove a DLL (in my case)
  4. Create a new CAB file with the updated contents, using IZARC 
  5. Rename the newly created CAB to WSP
  6. Install to SharePoint

——————–

NB. I’m using a WSP for the SharePoint Reporting Services webparts – just as an example – RSWebParts.wsp

As mentioned, the first steps are to rename the WSP to CAB, and extract the contents to a folder.

You don’t HAVE to use IZArc for this step; you could do using WinZip, or WinRAR – or even the default Windows Explorer.

image

Next – go into the folder, and change whatever you need – such as DLL’s or XML’s, whatever.  

For this example, I’m going to remove the language sets for DE, ES, FR, IT (German, Spanish, French & Italian).   No reason – other than to ‘invent’ a change for this post – I don’t have anything against the European Union – honest !  

image

The next step is to create a new WSP – by re-CAB’ing these files – and here’s the trick that caught me out.

You may be tempted to simply do CTRL-A – and then RIGHT-CLICK > IZArc > ‘Add to Archive File’

But – this won’t allow you do sub-folders – I don’t know why !!

image

See…>    !?!!?

image

Instead – the steps you need to do are these :

  1. Open IZArc as a ‘program’
  2. Create a new archive
  3. Choose a CAB file type
  4. Add the files – and check the box for “subfolders”

——————–

So – let’s give it a go :

  • Click Start > LZArc
  • Click New
  • Give the new archive a name – eg. NewRSWebParts (can change it later)

image

The next window has two tabs – Selection – and Options

  • Firstly select all the files you need for the new WSP – in the Selection tab
  • I chose the folder and then did CTRL-A to select all the files needed

image

NEXT – switch to the Options tab >

  • Change the archive type to be “CAB”
  • Check the box for “Include sub-folders”
  • Click OK

image

After half a milli-second, you’ll have your new CAB file.

  • Can then click the big red “Exit” button – as we’re done with LZArc.
  • Switch back to Windows Explorer
  • Re-name the newly created CAB file –> WSP extension.

image

And – that’s it !

Only took a few steps to create a new WSP file – with updated contents – without needing Visual Studio – or WSP Builder !

Just remember that you might need to update your initial projects back in TFS, or Visual Studio anyway.

This is just for those emergency updates – or if you don’t have the source code/project.

Very nice indeed – very easy – and extremely useful !   

Nerd smile

Advertisement
11 Comments leave one →
  1. September 9, 2010 8:43 pm

    If you need to apply changes in a WSP package that is created using the Visual Studio 2010 SharePoint Tools you can do this by adding an AfterLayout target in the SharePoint project .csproj MSBuild file. In the AfterLayout target you get the LayoutPath value that points to the temp folder containing the WSP file contents and the manifest.xml file. You can add/remove files in this folder and modify the manifest.xml file.

    Have fun!

    Regards,
    Serge

  2. February 9, 2011 3:04 pm

    Thanks so much for this–I got frustrated with how tedious editing a wsp was a while back. There is a way to avoid the subfolder issue by creating the archive as a plain old zip and then using Tools > Convert Archive to output it to a cab file. I blogged about it here but the Convert Archive is all you really need to know.

  3. June 2, 2011 5:13 pm

    SharePoint list template files (.stp) are also comprised of a singular manifest.xml file compressed into a .cab and then the extension is changed to .stp

    I tried to modify some of the data that was saved into a particular .stp file that I had on hand, and then tried to re-compress the manifest.xml using the technique described above with IZarc. I then changed the extension back to “.stp”, but when I upload the file into my site’s List Templates, I get an error saying ‘manifest.xml not found’

    Would be interested to know if anyone else has encountered this.

    • Chandrani permalink
      October 25, 2011 10:03 am

      Hi bkwdesign,
      i also got a similar problem while using .wsp files.

      • Jorge permalink
        November 16, 2011 11:56 pm

        I got that manifest.xml error reply when I re-CAB the files without looking at the full steps described above. If you just re-CAB them with RIGHT-CLICK > IZArc > ‘Add to Archive File’
        it won’t create the subfolders and that’s why it can’t find the manifest.xml. You have to do it as described above (or any other way that keeps the subolders structure) and you won’t have this problem.

  4. John permalink
    August 15, 2011 1:43 am

    I just wanted to thank you for the post. It really helped me. Thank you!

  5. rijusharepoint permalink
    September 3, 2011 5:13 am

    Nothing really happened. 1st half of the experiment was fine.Again making the extracted file cab didnt work out in xp .

  6. Brian P permalink
    October 31, 2011 6:33 pm

    SharePoint did not like the WSP if I created a new CAB and added files to it. Clark’s method worked perfectly though. Extract original WSP files, make edits, add all files to new ZIP file, then open the ZIP with IZarc and choose Tools-Convert Archive to CAB. Renamed as WSP and upload/activation worked first try.

  7. Felipe permalink
    November 25, 2011 12:07 pm

    Great post man… saved me a lot of time :)

  8. Carsten Keutmann permalink
    December 30, 2011 3:59 pm

    WSPBuilder is able to extract a WSP file to a folder, then edit the files you whant to change and repacked the wsp by running WSPBuilder on the extracted folder. Job done!

    http://keutmann.blogspot.com/2010/04/extract-wsp-packages-with-wspbuilder.html

Trackbacks

  1. How To Create Bamboo Community Central As Top-Level Site « haiquangitvn

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.